1 | var memoizeCapped = require('./_memoizeCapped');
|
2 |
|
3 |
|
4 | var reLeadingDot = /^\./,
|
5 | rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
6 |
|
7 |
|
8 | var reEscapeChar = /\\(\\)?/g;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
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;
|