mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
var baseFlatten = require('../internal/baseFlatten'),
|
||||
bindCallback = require('../internal/bindCallback'),
|
||||
pickByArray = require('../internal/pickByArray'),
|
||||
pickByCallback = require('../internal/pickByCallback');
|
||||
pickByCallback = require('../internal/pickByCallback'),
|
||||
restParam = require('../function/restParam');
|
||||
|
||||
/**
|
||||
* Creates an object composed of the picked `object` properties. Property
|
||||
* names may be specified as individual arguments or as arrays of property
|
||||
* names. If `predicate` is provided it is invoked for each property of `object`
|
||||
* picking the properties `predicate` returns truthy for. The predicate is
|
||||
* bound to `thisArg` and invoked with three arguments; (value, key, object).
|
||||
* bound to `thisArg` and invoked with three arguments: (value, key, object).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -29,13 +30,13 @@ var baseFlatten = require('../internal/baseFlatten'),
|
||||
* _.pick(object, _.isString);
|
||||
* // => { 'user': 'fred' }
|
||||
*/
|
||||
function pick(object, predicate, thisArg) {
|
||||
var pick = restParam(function(object, props) {
|
||||
if (object == null) {
|
||||
return {};
|
||||
}
|
||||
return typeof predicate == 'function'
|
||||
? pickByCallback(object, bindCallback(predicate, thisArg, 3))
|
||||
: pickByArray(object, baseFlatten(arguments, false, false, 1));
|
||||
}
|
||||
return typeof props[0] == 'function'
|
||||
? pickByCallback(object, bindCallback(props[0], props[1], 3))
|
||||
: pickByArray(object, baseFlatten(props));
|
||||
});
|
||||
|
||||
module.exports = pick;
|
||||
|
||||
Reference in New Issue
Block a user