source: trip-planner-front/node_modules/lodash/toPath.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 804 bytes
Line 
1var arrayMap = require('./_arrayMap'),
2 copyArray = require('./_copyArray'),
3 isArray = require('./isArray'),
4 isSymbol = require('./isSymbol'),
5 stringToPath = require('./_stringToPath'),
6 toKey = require('./_toKey'),
7 toString = require('./toString');
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 */
26function toPath(value) {
27 if (isArray(value)) {
28 return arrayMap(value, toKey);
29 }
30 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
31}
32
33module.exports = toPath;
Note: See TracBrowser for help on using the repository browser.