1 | var arrayMap = require('./_arrayMap'),
|
2 | basePick = require('./_basePick'),
|
3 | flatRest = require('./_flatRest'),
|
4 | toKey = require('./_toKey');
|
5 |
|
6 | /**
|
7 | * Creates an object composed of the picked `object` properties.
|
8 | *
|
9 | * @static
|
10 | * @since 0.1.0
|
11 | * @memberOf _
|
12 | * @category Object
|
13 | * @param {Object} object The source object.
|
14 | * @param {...(string|string[])} [paths] The property paths to pick.
|
15 | * @returns {Object} Returns the new object.
|
16 | * @example
|
17 | *
|
18 | * var object = { 'a': 1, 'b': '2', 'c': 3 };
|
19 | *
|
20 | * _.pick(object, ['a', 'c']);
|
21 | * // => { 'a': 1, 'c': 3 }
|
22 | */
|
23 | var pick = flatRest(function(object, paths) {
|
24 | return object == null ? {} : basePick(object, arrayMap(paths, toKey));
|
25 | });
|
26 |
|
27 | module.exports = pick;
|