Files
lodash/at.js
John-David Dalton ce0b51888c Bump to v4.7.0.
2016-03-31 00:36:47 -07:00

31 lines
772 B
JavaScript

import baseAt from './_baseAt';
import baseFlatten from './_baseFlatten';
import rest from './rest';
/**
* Creates an array of values corresponding to `paths` of `object`.
*
* @static
* @memberOf _
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths of elements to pick,
* specified individually or in arrays.
* @returns {Array} Returns the new array of picked elements.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
*
* _.at(object, ['a[0].b.c', 'a[1]']);
* // => [3, 4]
*
* _.at(['a', 'b', 'c'], 0, 2);
* // => ['a', 'c']
*/
var at = rest(function(object, paths) {
return baseAt(object, baseFlatten(paths, 1));
});
export default at;