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