a zip code crypto-currency system good for red ONLY

toPath.js 804B

12345678910111213141516171819202122232425262728293031323334
  1. var 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. * Converts `value` to a property path array.
  10. *
  11. * @static
  12. * @memberOf _
  13. * @since 4.0.0
  14. * @category Util
  15. * @param {*} value The value to convert.
  16. * @returns {Array} Returns the new property path array.
  17. * @example
  18. *
  19. * _.toPath('a.b.c');
  20. * // => ['a', 'b', 'c']
  21. *
  22. * _.toPath('a[0].b.c');
  23. * // => ['a', '0', 'b', 'c']
  24. */
  25. function toPath(value) {
  26. if (isArray(value)) {
  27. return arrayMap(value, toKey);
  28. }
  29. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  30. }
  31. module.exports = toPath;