react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / object / omit.js
80742 viewsvar arrayMap = require('../internal/arrayMap'),1baseDifference = require('../internal/baseDifference'),2baseFlatten = require('../internal/baseFlatten'),3bindCallback = require('../internal/bindCallback'),4keysIn = require('./keysIn'),5pickByArray = require('../internal/pickByArray'),6pickByCallback = require('../internal/pickByCallback'),7restParam = require('../function/restParam');89/**10* The opposite of `_.pick`; this method creates an object composed of the11* own and inherited enumerable properties of `object` that are not omitted.12*13* @static14* @memberOf _15* @category Object16* @param {Object} object The source object.17* @param {Function|...(string|string[])} [predicate] The function invoked per18* iteration or property names to omit, specified as individual property19* names or arrays of property names.20* @param {*} [thisArg] The `this` binding of `predicate`.21* @returns {Object} Returns the new object.22* @example23*24* var object = { 'user': 'fred', 'age': 40 };25*26* _.omit(object, 'age');27* // => { 'user': 'fred' }28*29* _.omit(object, _.isNumber);30* // => { 'user': 'fred' }31*/32var omit = restParam(function(object, props) {33if (object == null) {34return {};35}36if (typeof props[0] != 'function') {37var props = arrayMap(baseFlatten(props), String);38return pickByArray(object, baseDifference(keysIn(object), props));39}40var predicate = bindCallback(props[0], props[1], 3);41return pickByCallback(object, function(value, key, object) {42return !predicate(value, key, object);43});44});4546module.exports = omit;474849