1234567891011121314151617181920212223242526272829303132 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- Object.defineProperty(exports, "toPath", {
- enumerable: true,
- get: function() {
- return toPath;
- }
- });
- function toPath(path) {
- if (Array.isArray(path)) return path;
- let openBrackets = path.split("[").length - 1;
- let closedBrackets = path.split("]").length - 1;
- if (openBrackets !== closedBrackets) {
- throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`);
- }
- return path.split(/\.(?![^\[]*\])|[\[\]]/g).filter(Boolean);
- }
|