1 var arrayMap = require('../internal/arrayMap'),
2 baseDifference = require('../internal/baseDifference'),
3 baseFlatten = require('../internal/baseFlatten'),
4 bindCallback = require('../internal/bindCallback'),
5 keysIn = require('./keysIn'),
6 pickByArray = require('../internal/pickByArray'),
7 pickByCallback = require('../internal/pickByCallback'),
8 restParam = require('../function/restParam');
11 * The opposite of `_.pick`; this method creates an object composed of the
12 * own and inherited enumerable properties of `object` that are not omitted.
13 * Property names may be specified as individual arguments or as arrays of
14 * property names. If `predicate` is provided it is invoked for each property
15 * of `object` omitting the properties `predicate` returns truthy for. The
16 * predicate is bound to `thisArg` and invoked with three arguments:
17 * (value, key, object).
22 * @param {Object} object The source object.
23 * @param {Function|...(string|string[])} [predicate] The function invoked per
24 * iteration or property names to omit, specified as individual property
25 * names or arrays of property names.
26 * @param {*} [thisArg] The `this` binding of `predicate`.
27 * @returns {Object} Returns the new object.
30 * var object = { 'user': 'fred', 'age': 40 };
32 * _.omit(object, 'age');
33 * // => { 'user': 'fred' }
35 * _.omit(object, _.isNumber);
36 * // => { 'user': 'fred' }
38 var omit = restParam(function(object, props) {
42 if (typeof props[0] != 'function') {
43 var props = arrayMap(baseFlatten(props), String);
44 return pickByArray(object, baseDifference(keysIn(object), props));
46 var predicate = bindCallback(props[0], props[1], 3);
47 return pickByCallback(object, function(value, key, object) {
48 return !predicate(value, key, object);
52 module.exports = omit;