Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var baseAt = require('../internal/baseAt'),
2
baseFlatten = require('../internal/baseFlatten'),
3
restParam = require('../function/restParam');
4
5
/**
6
* Creates an array of elements corresponding to the given keys, or indexes,
7
* of `collection`. Keys may be specified as individual arguments or as arrays
8
* of keys.
9
*
10
* @static
11
* @memberOf _
12
* @category Collection
13
* @param {Array|Object|string} collection The collection to iterate over.
14
* @param {...(number|number[]|string|string[])} [props] The property names
15
* or indexes of elements to pick, specified individually or in arrays.
16
* @returns {Array} Returns the new array of picked elements.
17
* @example
18
*
19
* _.at(['a', 'b', 'c'], [0, 2]);
20
* // => ['a', 'c']
21
*
22
* _.at(['barney', 'fred', 'pebbles'], 0, 2);
23
* // => ['barney', 'pebbles']
24
*/
25
var at = restParam(function(collection, props) {
26
return baseAt(collection, baseFlatten(props));
27
});
28
29
module.exports = at;
30
31