react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / collection / every.js
80742 viewsvar arrayEvery = require('../internal/arrayEvery'),1baseCallback = require('../internal/baseCallback'),2baseEvery = require('../internal/baseEvery'),3isArray = require('../lang/isArray'),4isIterateeCall = require('../internal/isIterateeCall');56/**7* Checks if `predicate` returns truthy for **all** elements of `collection`.8* The predicate is bound to `thisArg` and invoked with three arguments:9* (value, index|key, collection).10*11* If a property name is provided for `predicate` the created `_.property`12* style callback returns the property value of the given element.13*14* If a value is also provided for `thisArg` the created `_.matchesProperty`15* style callback returns `true` for elements that have a matching property16* value, else `false`.17*18* If an object is provided for `predicate` the created `_.matches` style19* callback returns `true` for elements that have the properties of the given20* object, else `false`.21*22* @static23* @memberOf _24* @alias all25* @category Collection26* @param {Array|Object|string} collection The collection to iterate over.27* @param {Function|Object|string} [predicate=_.identity] The function invoked28* per iteration.29* @param {*} [thisArg] The `this` binding of `predicate`.30* @returns {boolean} Returns `true` if all elements pass the predicate check,31* else `false`.32* @example33*34* _.every([true, 1, null, 'yes'], Boolean);35* // => false36*37* var users = [38* { 'user': 'barney', 'active': false },39* { 'user': 'fred', 'active': false }40* ];41*42* // using the `_.matches` callback shorthand43* _.every(users, { 'user': 'barney', 'active': false });44* // => false45*46* // using the `_.matchesProperty` callback shorthand47* _.every(users, 'active', false);48* // => true49*50* // using the `_.property` callback shorthand51* _.every(users, 'active');52* // => false53*/54function every(collection, predicate, thisArg) {55var func = isArray(collection) ? arrayEvery : baseEvery;56if (thisArg && isIterateeCall(collection, predicate, thisArg)) {57predicate = null;58}59if (typeof predicate != 'function' || thisArg !== undefined) {60predicate = baseCallback(predicate, thisArg, 3);61}62return func(collection, predicate);63}6465module.exports = every;666768