Loosen restrictions of _.intersection and others to accept array-like objects and add isArrayLike helper. [closes #1163]

This commit is contained in:
jdalton
2015-04-28 09:18:32 -07:00
parent bf89287c56
commit 2c6d880542
2 changed files with 42 additions and 49 deletions

View File

@@ -3855,12 +3855,11 @@
deepEqual(_.difference([1, NaN, 3], largeArray), [1, 3]);
});
test('should ignore values that are not arrays or `arguments` objects', 4, function() {
test('should ignore values that are not array-like', 3, function() {
var array = [1, null, 3];
deepEqual(_.difference(args, 3, { '0': 1 }), [1, 2, 3]);
deepEqual(_.difference(null, array, 1), []);
deepEqual(_.difference(array, args, null), [null]);
deepEqual(_.difference('abc', array, 'b'), []);
});
}(1, 2, 3));
@@ -16532,10 +16531,6 @@
var array = [1, 2, 3, 1, 2, 3];
deepEqual(_.without(array, 1, 2), [3, 3]);
});
test('should treat string values for `array` as empty', 1, function() {
deepEqual(_.without('abc', 'b'), []);
});
}(1, 2, 3));
/*--------------------------------------------------------------------------*/