Move internal modules to “internal” folder.

This commit is contained in:
John-David Dalton
2017-01-10 00:44:25 -08:00
parent 2b05673125
commit 26ea38dcf4
500 changed files with 726 additions and 726 deletions

27
.internal/stringToPath.js Normal file
View File

@@ -0,0 +1,27 @@
import memoizeCapped from './.internal/memoizeCapped.js';
/** Used to match property names within property paths. */
const reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/** Used to match backslashes in property paths. */
const reEscapeChar = /\\(\\)?/g;
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
const stringToPath = memoizeCapped(string => {
const result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, (match, number, quote, string) => {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;
});
export default stringToPath;