react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / object / pick.js
80742 viewsvar baseFlatten = require('../internal/baseFlatten'),1bindCallback = require('../internal/bindCallback'),2pickByArray = require('../internal/pickByArray'),3pickByCallback = require('../internal/pickByCallback'),4restParam = require('../function/restParam');56/**7* Creates an object composed of the picked `object` properties. Property8* names may be specified as individual arguments or as arrays of property9* names. If `predicate` is provided it is invoked for each property of `object`10* picking the properties `predicate` returns truthy for. The predicate is11* bound to `thisArg` and invoked with three arguments: (value, key, object).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 pick, 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* _.pick(object, 'user');27* // => { 'user': 'fred' }28*29* _.pick(object, _.isString);30* // => { 'user': 'fred' }31*/32var pick = restParam(function(object, props) {33if (object == null) {34return {};35}36return typeof props[0] == 'function'37? pickByCallback(object, bindCallback(props[0], props[1], 3))38: pickByArray(object, baseFlatten(props));39});4041module.exports = pick;424344