mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Add isIterateeCall guards to _.every and _.some. [closes #1035]
This commit is contained in:
@@ -6040,6 +6040,9 @@
|
||||
*/
|
||||
function every(collection, predicate, thisArg) {
|
||||
var func = isArray(collection) ? arrayEvery : baseEvery;
|
||||
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||
predicate = null;
|
||||
}
|
||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
}
|
||||
@@ -6476,9 +6479,9 @@
|
||||
*
|
||||
* The guarded methods are:
|
||||
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
||||
* `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`,
|
||||
* `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`,
|
||||
* `trunc`, `random`, `range`, `sample`, `uniq`, and `words`
|
||||
* `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
|
||||
* `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
|
||||
* `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -6867,6 +6870,9 @@
|
||||
*/
|
||||
function some(collection, predicate, thisArg) {
|
||||
var func = isArray(collection) ? arraySome : baseSome;
|
||||
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||
predicate = null;
|
||||
}
|
||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||
predicate = getCallback(predicate, thisArg, 3);
|
||||
}
|
||||
|
||||
10
test/test.js
10
test/test.js
@@ -4276,6 +4276,11 @@
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should work as an iteratee for `_.map`', 1, function() {
|
||||
var actual = _.map([[1]], _.every);
|
||||
deepEqual(actual, [true]);
|
||||
});
|
||||
|
||||
test('should be aliased', 1, function() {
|
||||
strictEqual(_.all, _.every);
|
||||
});
|
||||
@@ -12954,6 +12959,11 @@
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should work as an iteratee for `_.map`', 1, function() {
|
||||
var actual = _.map([[1]], _.some);
|
||||
deepEqual(actual, [true]);
|
||||
});
|
||||
|
||||
test('should be aliased', 1, function() {
|
||||
strictEqual(_.any, _.some);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user