source: imaps-frontend/node_modules/lodash-es/every.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import arrayEvery from './_arrayEvery.js';
2import baseEvery from './_baseEvery.js';
3import baseIteratee from './_baseIteratee.js';
4import isArray from './isArray.js';
5import isIterateeCall from './_isIterateeCall.js';
6
7/**
8 * Checks if `predicate` returns truthy for **all** elements of `collection`.
9 * Iteration is stopped once `predicate` returns falsey. The predicate is
10 * invoked with three arguments: (value, index|key, collection).
11 *
12 * **Note:** This method returns `true` for
13 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
14 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
15 * elements of empty collections.
16 *
17 * @static
18 * @memberOf _
19 * @since 0.1.0
20 * @category Collection
21 * @param {Array|Object} collection The collection to iterate over.
22 * @param {Function} [predicate=_.identity] The function invoked per iteration.
23 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
24 * @returns {boolean} Returns `true` if all elements pass the predicate check,
25 * else `false`.
26 * @example
27 *
28 * _.every([true, 1, null, 'yes'], Boolean);
29 * // => false
30 *
31 * var users = [
32 * { 'user': 'barney', 'age': 36, 'active': false },
33 * { 'user': 'fred', 'age': 40, 'active': false }
34 * ];
35 *
36 * // The `_.matches` iteratee shorthand.
37 * _.every(users, { 'user': 'barney', 'active': false });
38 * // => false
39 *
40 * // The `_.matchesProperty` iteratee shorthand.
41 * _.every(users, ['active', false]);
42 * // => true
43 *
44 * // The `_.property` iteratee shorthand.
45 * _.every(users, 'active');
46 * // => false
47 */
48function every(collection, predicate, guard) {
49 var func = isArray(collection) ? arrayEvery : baseEvery;
50 if (guard && isIterateeCall(collection, predicate, guard)) {
51 predicate = undefined;
52 }
53 return func(collection, baseIteratee(predicate, 3));
54}
55
56export default every;
Note: See TracBrowser for help on using the repository browser.