main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
802 bytes
|
Line | |
---|
1 | import arrayMap from './_arrayMap.js';
|
---|
2 | import copyArray from './_copyArray.js';
|
---|
3 | import isArray from './isArray.js';
|
---|
4 | import isSymbol from './isSymbol.js';
|
---|
5 | import stringToPath from './_stringToPath.js';
|
---|
6 | import toKey from './_toKey.js';
|
---|
7 | import toString from './toString.js';
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * Converts `value` to a property path array.
|
---|
11 | *
|
---|
12 | * @static
|
---|
13 | * @memberOf _
|
---|
14 | * @since 4.0.0
|
---|
15 | * @category Util
|
---|
16 | * @param {*} value The value to convert.
|
---|
17 | * @returns {Array} Returns the new property path array.
|
---|
18 | * @example
|
---|
19 | *
|
---|
20 | * _.toPath('a.b.c');
|
---|
21 | * // => ['a', 'b', 'c']
|
---|
22 | *
|
---|
23 | * _.toPath('a[0].b.c');
|
---|
24 | * // => ['a', '0', 'b', 'c']
|
---|
25 | */
|
---|
26 | function toPath(value) {
|
---|
27 | if (isArray(value)) {
|
---|
28 | return arrayMap(value, toKey);
|
---|
29 | }
|
---|
30 | return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
|
---|
31 | }
|
---|
32 |
|
---|
33 | export default toPath;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.