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