mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Remove baseIteratee and castFunction.
This commit is contained in:
22
some.js
22
some.js
@@ -1,5 +1,4 @@
|
||||
import arraySome from './_arraySome.js';
|
||||
import baseIteratee from './_baseIteratee.js';
|
||||
import baseSome from './_baseSome.js';
|
||||
import isArray from './isArray.js';
|
||||
import isIterateeCall from './_isIterateeCall.js';
|
||||
@@ -14,7 +13,7 @@ import isIterateeCall from './_isIterateeCall.js';
|
||||
* @since 0.1.0
|
||||
* @category Collection
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||
* else `false`.
|
||||
@@ -22,30 +21,13 @@ import isIterateeCall from './_isIterateeCall.js';
|
||||
*
|
||||
* _.some([null, 0, 'yes', false], Boolean);
|
||||
* // => true
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney', 'active': true },
|
||||
* { 'user': 'fred', 'active': false }
|
||||
* ];
|
||||
*
|
||||
* // The `_.matches` iteratee shorthand.
|
||||
* _.some(users, { 'user': 'barney', 'active': false });
|
||||
* // => false
|
||||
*
|
||||
* // The `_.matchesProperty` iteratee shorthand.
|
||||
* _.some(users, ['active', false]);
|
||||
* // => true
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.some(users, 'active');
|
||||
* // => true
|
||||
*/
|
||||
function some(collection, predicate, guard) {
|
||||
const func = isArray(collection) ? arraySome : baseSome;
|
||||
if (guard && isIterateeCall(collection, predicate, guard)) {
|
||||
predicate = undefined;
|
||||
}
|
||||
return func(collection, baseIteratee(predicate, 3));
|
||||
return func(collection, predicate);
|
||||
}
|
||||
|
||||
export default some;
|
||||
|
||||
Reference in New Issue
Block a user