main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
838 bytes
|
Line | |
---|
1 | import memoizeCapped from './_memoizeCapped.js';
|
---|
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 | var stringToPath = memoizeCapped(function(string) {
|
---|
17 | var result = [];
|
---|
18 | if (string.charCodeAt(0) === 46 /* . */) {
|
---|
19 | result.push('');
|
---|
20 | }
|
---|
21 | string.replace(rePropName, function(match, number, quote, subString) {
|
---|
22 | result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
---|
23 | });
|
---|
24 | return result;
|
---|
25 | });
|
---|
26 |
|
---|
27 | export default stringToPath;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.