react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / collection / reject.js
80742 viewsvar arrayFilter = require('../internal/arrayFilter'),1baseCallback = require('../internal/baseCallback'),2baseFilter = require('../internal/baseFilter'),3isArray = require('../lang/isArray');45/**6* The opposite of `_.filter`; this method returns the elements of `collection`7* that `predicate` does **not** return truthy for.8*9* @static10* @memberOf _11* @category Collection12* @param {Array|Object|string} collection The collection to iterate over.13* @param {Function|Object|string} [predicate=_.identity] The function invoked14* per iteration.15* @param {*} [thisArg] The `this` binding of `predicate`.16* @returns {Array} Returns the new filtered array.17* @example18*19* _.reject([1, 2, 3, 4], function(n) {20* return n % 2 == 0;21* });22* // => [1, 3]23*24* var users = [25* { 'user': 'barney', 'age': 36, 'active': false },26* { 'user': 'fred', 'age': 40, 'active': true }27* ];28*29* // using the `_.matches` callback shorthand30* _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');31* // => ['barney']32*33* // using the `_.matchesProperty` callback shorthand34* _.pluck(_.reject(users, 'active', false), 'user');35* // => ['fred']36*37* // using the `_.property` callback shorthand38* _.pluck(_.reject(users, 'active'), 'user');39* // => ['barney']40*/41function reject(collection, predicate, thisArg) {42var func = isArray(collection) ? arrayFilter : baseFilter;43predicate = baseCallback(predicate, thisArg, 3);44return func(collection, function(value, index, collection) {45return !predicate(value, index, collection);46});47}4849module.exports = reject;505152