Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / object / omit.js
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');
9
10 /**
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  *
14  * @static
15  * @memberOf _
16  * @category Object
17  * @param {Object} object The source object.
18  * @param {Function|...(string|string[])} [predicate] The function invoked per
19  *  iteration or property names to omit, specified as individual property
20  *  names or arrays of property names.
21  * @param {*} [thisArg] The `this` binding of `predicate`.
22  * @returns {Object} Returns the new object.
23  * @example
24  *
25  * var object = { 'user': 'fred', 'age': 40 };
26  *
27  * _.omit(object, 'age');
28  * // => { 'user': 'fred' }
29  *
30  * _.omit(object, _.isNumber);
31  * // => { 'user': 'fred' }
32  */
33 var omit = restParam(function(object, props) {
34   if (object == null) {
35     return {};
36   }
37   if (typeof props[0] != 'function') {
38     var props = arrayMap(baseFlatten(props), String);
39     return pickByArray(object, baseDifference(keysIn(object), props));
40   }
41   var predicate = bindCallback(props[0], props[1], 3);
42   return pickByCallback(object, function(value, key, object) {
43     return !predicate(value, key, object);
44   });
45 });
46
47 module.exports = omit;