Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_stringToPath.js 840B

123456789101112131415161718192021222324252627
  1. var memoizeCapped = require('./_memoizeCapped');
  2. /** Used to match property names within property paths. */
  3. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  4. /** Used to match backslashes in property paths. */
  5. var reEscapeChar = /\\(\\)?/g;
  6. /**
  7. * Converts `string` to a property path array.
  8. *
  9. * @private
  10. * @param {string} string The string to convert.
  11. * @returns {Array} Returns the property path array.
  12. */
  13. var stringToPath = memoizeCapped(function(string) {
  14. var result = [];
  15. if (string.charCodeAt(0) === 46 /* . */) {
  16. result.push('');
  17. }
  18. string.replace(rePropName, function(match, number, quote, subString) {
  19. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  20. });
  21. return result;
  22. });
  23. module.exports = stringToPath;