Ensure "Arrays" and "Objects" methods work with arguments objects and arrays respectively.

Former-commit-id: aebb7a0004d804b7fd43d73e24d1da28c67f4059
This commit is contained in:
John-David Dalton
2013-04-07 15:10:03 -07:00
parent 93df901b71
commit 43037c0ff9
3 changed files with 100 additions and 32 deletions

View File

@@ -168,7 +168,7 @@
'times': ['createCallback'],
'toArray': ['isString', 'values'],
'unescape': [],
'union': ['uniq'],
'union': ['isArray', 'uniq'],
'uniq': ['createCallback', 'indexOf'],
'uniqueId': [],
'unzip': ['max', 'pluck'],
@@ -2030,12 +2030,12 @@
'function difference(array) {',
' var index = -1,',
' length = array.length,',
' flattened = concat.apply(arrayRef, arguments),',
' flattened = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),',
' result = [];',
'',
' while (++index < length) {',
' var value = array[index];',
' if (indexOf(flattened, value, length) < 0) {',
' if (indexOf(flattened, value) < 0) {',
' result.push(value);',
' }',
' }',
@@ -2219,11 +2219,11 @@
// replace `_.omit`
source = replaceFunction(source, 'omit', [
'function omit(object) {',
' var props = concat.apply(arrayRef, arguments),',
' var props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),',
' result = {};',
'',
' forIn(object, function(value, key) {',
' if (indexOf(props, key, 1) < 0) {',
' if (indexOf(props, key) < 0) {',
' result[key] = value;',
' }',
' });',
@@ -2234,8 +2234,8 @@
// replace `_.pick`
source = replaceFunction(source, 'pick', [
'function pick(object) {',
' var index = 0,',
' props = concat.apply(arrayRef, arguments),',
' var index = -1,',
' props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),',
' length = props.length,',
' result = {};',
'',