1 var arrayFilter = require('../internal/arrayFilter'),
2 baseCallback = require('../internal/baseCallback'),
3 baseFilter = require('../internal/baseFilter'),
4 isArray = require('../lang/isArray');
7 * The opposite of `_.filter`; this method returns the elements of `collection`
8 * that `predicate` does **not** return truthy for.
12 * @category Collection
13 * @param {Array|Object|string} collection The collection to iterate over.
14 * @param {Function|Object|string} [predicate=_.identity] The function invoked
16 * @param {*} [thisArg] The `this` binding of `predicate`.
17 * @returns {Array} Returns the new filtered array.
20 * _.reject([1, 2, 3, 4], function(n) {
26 * { 'user': 'barney', 'age': 36, 'active': false },
27 * { 'user': 'fred', 'age': 40, 'active': true }
30 * // using the `_.matches` callback shorthand
31 * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');
34 * // using the `_.matchesProperty` callback shorthand
35 * _.pluck(_.reject(users, 'active', false), 'user');
38 * // using the `_.property` callback shorthand
39 * _.pluck(_.reject(users, 'active'), 'user');
42 function reject(collection, predicate, thisArg) {
43 var func = isArray(collection) ? arrayFilter : baseFilter;
44 predicate = baseCallback(predicate, thisArg, 3);
45 return func(collection, function(value, index, collection) {
46 return !predicate(value, index, collection);
50 module.exports = reject;