forked from lodash/lodash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
at.js
21 lines (19 loc) · 594 Bytes
/
at.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import baseAt from './.internal/baseAt.js'
import baseFlatten from './.internal/baseFlatten.js'
/**
* Creates an array of values corresponding to `paths` of `object`.
*
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Array} Returns the picked values.
* @example
*
* const object = { 'a': [{ 'b': { 'c': 3 } }, 4] }
*
* at(object, ['a[0].b.c', 'a[1]'])
* // => [3, 4]
*/
const at = (object, ...paths) => baseAt(object, baseFlatten(paths, 1))
export default at