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.
10 * If a property name is provided for `predicate` the created `_.property`
11 * style callback returns the property value of the given element.
13 * If a value is also provided for `thisArg` the created `_.matchesProperty`
14 * style callback returns `true` for elements that have a matching property
15 * value, else `false`.
17 * If an object is provided for `predicate` the created `_.matches` style
18 * callback returns `true` for elements that have the properties of the given
19 * object, else `false`.
23 * @category Collection
24 * @param {Array|Object|string} collection The collection to iterate over.
25 * @param {Function|Object|string} [predicate=_.identity] The function invoked
27 * @param {*} [thisArg] The `this` binding of `predicate`.
28 * @returns {Array} Returns the new filtered array.
31 * _.reject([1, 2, 3, 4], function(n) {
37 * { 'user': 'barney', 'age': 36, 'active': false },
38 * { 'user': 'fred', 'age': 40, 'active': true }
41 * // using the `_.matches` callback shorthand
42 * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');
45 * // using the `_.matchesProperty` callback shorthand
46 * _.pluck(_.reject(users, 'active', false), 'user');
49 * // using the `_.property` callback shorthand
50 * _.pluck(_.reject(users, 'active'), 'user');
53 function reject(collection, predicate, thisArg) {
54 var func = isArray(collection) ? arrayFilter : baseFilter;
55 predicate = baseCallback(predicate, thisArg, 3);
56 return func(collection, function(value, index, collection) {
57 return !predicate(value, index, collection);
61 module.exports = reject;