mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +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) {
|
function every(collection, predicate, thisArg) {
|
||||||
var func = isArray(collection) ? arrayEvery : baseEvery;
|
var func = isArray(collection) ? arrayEvery : baseEvery;
|
||||||
|
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||||
|
predicate = null;
|
||||||
|
}
|
||||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getCallback(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
@@ -6476,9 +6479,9 @@
|
|||||||
*
|
*
|
||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
||||||
* `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`,
|
* `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
|
||||||
* `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`,
|
* `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
|
||||||
* `trunc`, `random`, `range`, `sample`, `uniq`, and `words`
|
* `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -6867,6 +6870,9 @@
|
|||||||
*/
|
*/
|
||||||
function some(collection, predicate, thisArg) {
|
function some(collection, predicate, thisArg) {
|
||||||
var func = isArray(collection) ? arraySome : baseSome;
|
var func = isArray(collection) ? arraySome : baseSome;
|
||||||
|
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
||||||
|
predicate = null;
|
||||||
|
}
|
||||||
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||||
predicate = getCallback(predicate, thisArg, 3);
|
predicate = getCallback(predicate, thisArg, 3);
|
||||||
}
|
}
|
||||||
|
|||||||
10
test/test.js
10
test/test.js
@@ -4276,6 +4276,11 @@
|
|||||||
deepEqual(actual, expected);
|
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() {
|
test('should be aliased', 1, function() {
|
||||||
strictEqual(_.all, _.every);
|
strictEqual(_.all, _.every);
|
||||||
});
|
});
|
||||||
@@ -12954,6 +12959,11 @@
|
|||||||
deepEqual(actual, expected);
|
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() {
|
test('should be aliased', 1, function() {
|
||||||
strictEqual(_.any, _.some);
|
strictEqual(_.any, _.some);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user