Avoid Array.prototype issues in Narwhal.

Former-commit-id: 47627a187d59fb83f4a5b84b03158432d5216395
This commit is contained in:
John-David Dalton
2013-06-10 11:54:09 -07:00
parent 1933a76631
commit 7f5c97d0be
2 changed files with 33 additions and 26 deletions

View File

@@ -18,10 +18,10 @@
var cwd = process.cwd();
/** Used for array method references */
var arrayProto = Array.prototype;
var arrayRef = Array.prototype;
/** Shortcut used to push arrays of values to an array */
var push = arrayProto.push;
var push = arrayRef.push;
/** Used to create regexes that may detect multi-line comment blocks */
var multilineComment = '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n';
@@ -30,7 +30,7 @@
var reNode = RegExp('(?:^|' + path.sepEscaped + ')node(?:\\.exe)?$');
/** Shortcut used to convert array-like objects to arrays */
var slice = arrayProto.slice;
var slice = arrayRef.slice;
/** Shortcut to the `stdout` object */
var stdout = process.stdout;
@@ -470,7 +470,7 @@
return indent + [
'// add `Array` mutator functions to the wrapper',
funcName + "(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {",
' var func = arrayProto[methodName];',
' var func = arrayRef[methodName];',
' lodash.prototype[methodName] = function() {',
' var value = this.__wrapped__;',
' func.apply(value, arguments);',
@@ -486,7 +486,7 @@
'',
'// add `Array` accessor functions to the wrapper',
funcName + "(['concat', 'join', 'slice'], function(methodName) {",
' var func = arrayProto[methodName];',
' var func = arrayRef[methodName];',
' lodash.prototype[methodName] = function() {',
' var value = this.__wrapped__,',
' result = func.apply(value, arguments);',
@@ -2434,7 +2434,7 @@
' var index = -1,',
' indexOf = getIndexOf(),',
' length = array.length,',
' flattened = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),',
' flattened = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),',
' result = [];',
'',
' while (++index < length) {',
@@ -2676,7 +2676,7 @@
source = replaceFunction(source, 'omit', [
'function omit(object) {',
' var indexOf = getIndexOf(),',
' props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),',
' props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),',
' result = {};',
'',
' forIn(object, function(value, key) {',
@@ -2693,7 +2693,7 @@
source = replaceFunction(source, 'pick', [
'function pick(object) {',
' var index = -1,',
' props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),',
' props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),',
' length = props.length,',
' result = {};',
'',