1 var baseFlatten = require('../internal/baseFlatten'),
2 bindCallback = require('../internal/bindCallback'),
3 pickByArray = require('../internal/pickByArray'),
4 pickByCallback = require('../internal/pickByCallback'),
5 restParam = require('../function/restParam');
8 * Creates an object composed of the picked `object` properties. Property
9 * names may be specified as individual arguments or as arrays of property
10 * names. If `predicate` is provided it's invoked for each property of `object`
11 * picking the properties `predicate` returns truthy for. The predicate is
12 * bound to `thisArg` and invoked with three arguments: (value, key, object).
17 * @param {Object} object The source object.
18 * @param {Function|...(string|string[])} [predicate] The function invoked per
19 * iteration or property names to pick, 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.
25 * var object = { 'user': 'fred', 'age': 40 };
27 * _.pick(object, 'user');
28 * // => { 'user': 'fred' }
30 * _.pick(object, _.isString);
31 * // => { 'user': 'fred' }
33 var pick = restParam(function(object, props) {
37 return typeof props[0] == 'function'
38 ? pickByCallback(object, bindCallback(props[0], props[1], 3))
39 : pickByArray(object, baseFlatten(props));
42 module.exports = pick;