mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -2,13 +2,14 @@ import baseFlatten from '../internal/baseFlatten';
|
||||
import bindCallback from '../internal/bindCallback';
|
||||
import pickByArray from '../internal/pickByArray';
|
||||
import pickByCallback from '../internal/pickByCallback';
|
||||
import restParam from '../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 @@ import pickByCallback from '../internal/pickByCallback';
|
||||
* _.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));
|
||||
});
|
||||
|
||||
export default pick;
|
||||
|
||||
Reference in New Issue
Block a user