@common.js/object-scan 20.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +5 -0
- package/lib/core/compiler-iterator.js +109 -0
- package/lib/core/compiler.js +164 -0
- package/lib/core/context.js +149 -0
- package/lib/core/find-result.js +77 -0
- package/lib/core/find-util.js +92 -0
- package/lib/core/find.js +297 -0
- package/lib/core/node-util.js +94 -0
- package/lib/core/node.js +151 -0
- package/lib/core/parser-ref.js +59 -0
- package/lib/core/parser-result.js +218 -0
- package/lib/core/parser-value.js +24 -0
- package/lib/core/parser.js +205 -0
- package/lib/generic/assert.js +16 -0
- package/lib/generic/helper.js +85 -0
- package/lib/generic/iterator.js +97 -0
- package/lib/index.js +97 -0
- package/lib/index.min.js +1443 -0
- package/package.json +81 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _assertJs = /*#__PURE__*/ _interopRequireDefault(require("../generic/assert.js"));
|
|
12
|
+
var _parserValueJs = require("./parser-value.js");
|
|
13
|
+
var _parserRefJs = require("./parser-ref.js");
|
|
14
|
+
function _arrayLikeToArray(arr, len) {
|
|
15
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
16
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
17
|
+
return arr2;
|
|
18
|
+
}
|
|
19
|
+
function _arrayWithHoles(arr) {
|
|
20
|
+
if (Array.isArray(arr)) return arr;
|
|
21
|
+
}
|
|
22
|
+
function _arrayWithoutHoles(arr) {
|
|
23
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
24
|
+
}
|
|
25
|
+
function _instanceof(left, right) {
|
|
26
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
27
|
+
return !!right[Symbol.hasInstance](left);
|
|
28
|
+
} else {
|
|
29
|
+
return left instanceof right;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function _interopRequireDefault(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function _iterableToArray(iter) {
|
|
38
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
39
|
+
}
|
|
40
|
+
function _iterableToArrayLimit(arr, i) {
|
|
41
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
42
|
+
if (_i == null) return;
|
|
43
|
+
var _arr = [];
|
|
44
|
+
var _n = true;
|
|
45
|
+
var _d = false;
|
|
46
|
+
var _s, _e;
|
|
47
|
+
try {
|
|
48
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
49
|
+
_arr.push(_s.value);
|
|
50
|
+
if (i && _arr.length === i) break;
|
|
51
|
+
}
|
|
52
|
+
} catch (err) {
|
|
53
|
+
_d = true;
|
|
54
|
+
_e = err;
|
|
55
|
+
} finally{
|
|
56
|
+
try {
|
|
57
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
58
|
+
} finally{
|
|
59
|
+
if (_d) throw _e;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return _arr;
|
|
63
|
+
}
|
|
64
|
+
function _nonIterableRest() {
|
|
65
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
66
|
+
}
|
|
67
|
+
function _nonIterableSpread() {
|
|
68
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
69
|
+
}
|
|
70
|
+
function _slicedToArray(arr, i) {
|
|
71
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
72
|
+
}
|
|
73
|
+
function _toConsumableArray(arr) {
|
|
74
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
75
|
+
}
|
|
76
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
77
|
+
if (!o) return;
|
|
78
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
79
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
80
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
81
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
82
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
83
|
+
}
|
|
84
|
+
var throwError = function(msg, input) {
|
|
85
|
+
var context = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
86
|
+
throw new Error(Object.entries(context).reduce(function(p, param) {
|
|
87
|
+
var _param = _slicedToArray(param, 2), k = _param[0], v = _param[1];
|
|
88
|
+
return "".concat(p, ", ").concat(k, " ").concat(v);
|
|
89
|
+
}, "".concat(msg, ": ").concat(input)));
|
|
90
|
+
};
|
|
91
|
+
var getSimple = function(arr) {
|
|
92
|
+
return arr.length === 1 ? arr[0] : arr;
|
|
93
|
+
};
|
|
94
|
+
var arraySelectorRegex = /^[?*+\d]+$/;
|
|
95
|
+
var _default = function(input) {
|
|
96
|
+
var cResult = [];
|
|
97
|
+
cResult.or = true;
|
|
98
|
+
var inArray = false;
|
|
99
|
+
var excludeNext = false;
|
|
100
|
+
var cursor = 0;
|
|
101
|
+
// group related
|
|
102
|
+
var parentStack = [];
|
|
103
|
+
var newChild = function(asOr) {
|
|
104
|
+
if (cResult.excluded === true) {
|
|
105
|
+
(0, _assertJs.default)(excludeNext === false);
|
|
106
|
+
excludeNext = true;
|
|
107
|
+
}
|
|
108
|
+
parentStack.push(cResult);
|
|
109
|
+
cResult = [];
|
|
110
|
+
cResult.or = asOr;
|
|
111
|
+
};
|
|
112
|
+
var finishChild = function() {
|
|
113
|
+
var parent = parentStack.pop();
|
|
114
|
+
var child = getSimple(cResult);
|
|
115
|
+
if (parent.or === true && child.or === true) {
|
|
116
|
+
var _parent;
|
|
117
|
+
(_parent = parent).push.apply(_parent, _toConsumableArray(child));
|
|
118
|
+
} else {
|
|
119
|
+
parent.push(child);
|
|
120
|
+
}
|
|
121
|
+
cResult = parent;
|
|
122
|
+
};
|
|
123
|
+
newChild(false);
|
|
124
|
+
return {
|
|
125
|
+
setInArray: function(flag, idx) {
|
|
126
|
+
if (inArray === flag) {
|
|
127
|
+
throwError(inArray ? "Bad Array Start" : "Bad Array Terminator", input, {
|
|
128
|
+
char: idx
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
inArray = flag;
|
|
132
|
+
},
|
|
133
|
+
finishElement: function(idx, err, fins) {
|
|
134
|
+
var ref = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, _finReq = ref.finReq, finReq = _finReq === void 0 ? false : _finReq, _group = ref.group, group = _group === void 0 ? false : _group;
|
|
135
|
+
var isFinished = cursor === idx;
|
|
136
|
+
if (isFinished) {
|
|
137
|
+
if (!fins.includes(input[idx - 1] || null)) {
|
|
138
|
+
throwError(err, input, {
|
|
139
|
+
char: idx
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
cursor += 1;
|
|
143
|
+
} else {
|
|
144
|
+
if (finReq) {
|
|
145
|
+
throwError(err, input, {
|
|
146
|
+
char: idx
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
var ele = input.slice(cursor, idx);
|
|
150
|
+
if (group && ![
|
|
151
|
+
"**",
|
|
152
|
+
"++"
|
|
153
|
+
].includes(ele)) {
|
|
154
|
+
throwError("Bad Group Start", input, {
|
|
155
|
+
char: idx
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (inArray && !(arraySelectorRegex.test(ele) || ele.startsWith("(") && ele.endsWith(")"))) {
|
|
159
|
+
throwError("Bad Array Selector", input, {
|
|
160
|
+
selector: ele
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (group) {
|
|
164
|
+
cResult.push(new _parserRefJs.Ref(ele));
|
|
165
|
+
} else {
|
|
166
|
+
cResult.push(new _parserValueJs.Value(inArray ? "[".concat(ele, "]") : ele, excludeNext));
|
|
167
|
+
excludeNext = false;
|
|
168
|
+
}
|
|
169
|
+
cursor = idx + 1;
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
startExclusion: function(idx) {
|
|
173
|
+
if (excludeNext !== false) {
|
|
174
|
+
throwError("Redundant Exclusion", input, {
|
|
175
|
+
char: idx
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
excludeNext = true;
|
|
179
|
+
},
|
|
180
|
+
startGroup: function() {
|
|
181
|
+
newChild(true);
|
|
182
|
+
if (excludeNext) {
|
|
183
|
+
cResult.excluded = true;
|
|
184
|
+
excludeNext = false;
|
|
185
|
+
}
|
|
186
|
+
newChild(false);
|
|
187
|
+
},
|
|
188
|
+
newGroupElement: function() {
|
|
189
|
+
finishChild();
|
|
190
|
+
newChild(false);
|
|
191
|
+
},
|
|
192
|
+
finishGroup: function(idx) {
|
|
193
|
+
if (parentStack.length < 2) {
|
|
194
|
+
throwError("Unexpected Group Terminator", input, {
|
|
195
|
+
char: idx
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
finishChild();
|
|
199
|
+
finishChild();
|
|
200
|
+
(0, _assertJs.default)(Array.isArray(cResult));
|
|
201
|
+
var refMaybe = cResult[cResult.length - 2];
|
|
202
|
+
if (_instanceof(refMaybe, _parserRefJs.Ref) && refMaybe.left === true) {
|
|
203
|
+
cResult.push(refMaybe.link);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
finalizeResult: function() {
|
|
207
|
+
finishChild();
|
|
208
|
+
(0, _assertJs.default)(excludeNext === false);
|
|
209
|
+
if (parentStack.length !== 0) {
|
|
210
|
+
throwError("Non Terminated Group", input);
|
|
211
|
+
}
|
|
212
|
+
if (inArray) {
|
|
213
|
+
throwError("Non Terminated Array", input);
|
|
214
|
+
}
|
|
215
|
+
return getSimple(cResult);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Value", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Value;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _classCallCheck(instance, Constructor) {
|
|
12
|
+
if (!(instance instanceof Constructor)) {
|
|
13
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
var Value = function Value(value, excluded) {
|
|
17
|
+
"use strict";
|
|
18
|
+
_classCallCheck(this, Value);
|
|
19
|
+
this.value = value;
|
|
20
|
+
this.excluded = excluded;
|
|
21
|
+
this.isSimpleStarRec = value === "**";
|
|
22
|
+
this.isRegexStarRec = value.startsWith("**(") && value.endsWith(")");
|
|
23
|
+
this.isStarRec = this.isSimpleStarRec || this.isRegexStarRec;
|
|
24
|
+
};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _parserValueJs = require("./parser-value.js");
|
|
12
|
+
var _parserResultJs = /*#__PURE__*/ _interopRequireDefault(require("./parser-result.js"));
|
|
13
|
+
function _arrayLikeToArray(arr, len) {
|
|
14
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
15
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
16
|
+
return arr2;
|
|
17
|
+
}
|
|
18
|
+
function _arrayWithHoles(arr) {
|
|
19
|
+
if (Array.isArray(arr)) return arr;
|
|
20
|
+
}
|
|
21
|
+
function _interopRequireDefault(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function _iterableToArrayLimit(arr, i) {
|
|
27
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
28
|
+
if (_i == null) return;
|
|
29
|
+
var _arr = [];
|
|
30
|
+
var _n = true;
|
|
31
|
+
var _d = false;
|
|
32
|
+
var _s, _e;
|
|
33
|
+
try {
|
|
34
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
35
|
+
_arr.push(_s.value);
|
|
36
|
+
if (i && _arr.length === i) break;
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
_d = true;
|
|
40
|
+
_e = err;
|
|
41
|
+
} finally{
|
|
42
|
+
try {
|
|
43
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
44
|
+
} finally{
|
|
45
|
+
if (_d) throw _e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return _arr;
|
|
49
|
+
}
|
|
50
|
+
function _nonIterableRest() {
|
|
51
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
52
|
+
}
|
|
53
|
+
function _slicedToArray(arr, i) {
|
|
54
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
55
|
+
}
|
|
56
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
57
|
+
if (!o) return;
|
|
58
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
59
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
60
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
61
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
62
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
63
|
+
}
|
|
64
|
+
var throwError = function(msg, input) {
|
|
65
|
+
var context = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
66
|
+
throw new Error(Object.entries(context).reduce(function(p, param) {
|
|
67
|
+
var _param = _slicedToArray(param, 2), k = _param[0], v = _param[1];
|
|
68
|
+
return "".concat(p, ", ").concat(k, " ").concat(v);
|
|
69
|
+
}, "".concat(msg, ": ").concat(input)));
|
|
70
|
+
};
|
|
71
|
+
var parse = function(input, ctx) {
|
|
72
|
+
if (input === "") {
|
|
73
|
+
return new _parserValueJs.Value("", false);
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(input)) {
|
|
76
|
+
if (input.length === 0) {
|
|
77
|
+
return new _parserValueJs.Value("", false);
|
|
78
|
+
}
|
|
79
|
+
return input.map(function(e, idx) {
|
|
80
|
+
if (typeof e === "number") {
|
|
81
|
+
if (!ctx.useArraySelector) {
|
|
82
|
+
throwError("Forbidden Array Selector", JSON.stringify(input), {
|
|
83
|
+
idx: idx
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return new _parserValueJs.Value("[".concat(e, "]"), false);
|
|
87
|
+
}
|
|
88
|
+
return new _parserValueJs.Value(e.replaceAll("\\", "\\\\"), false);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
var result = (0, _parserResultJs.default)(input);
|
|
92
|
+
var inputLength = input.length;
|
|
93
|
+
var escaped = false;
|
|
94
|
+
var bracketDepth = 0;
|
|
95
|
+
for(var idx = 0; idx < inputLength; idx += 1){
|
|
96
|
+
var char = input[idx];
|
|
97
|
+
if (escaped === false) {
|
|
98
|
+
if (bracketDepth === 0) {
|
|
99
|
+
switch(char){
|
|
100
|
+
case ".":
|
|
101
|
+
result.finishElement(idx, "Bad Path Separator", [
|
|
102
|
+
"]",
|
|
103
|
+
"}"
|
|
104
|
+
]);
|
|
105
|
+
break;
|
|
106
|
+
case "[":
|
|
107
|
+
if (!ctx.useArraySelector) {
|
|
108
|
+
throwError("Forbidden Array Selector", input, {
|
|
109
|
+
char: idx
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
result.finishElement(idx, "Bad Array Start", [
|
|
113
|
+
null,
|
|
114
|
+
"!",
|
|
115
|
+
"{",
|
|
116
|
+
",",
|
|
117
|
+
"}",
|
|
118
|
+
"]"
|
|
119
|
+
]);
|
|
120
|
+
result.setInArray(true, idx);
|
|
121
|
+
break;
|
|
122
|
+
case "]":
|
|
123
|
+
result.finishElement(idx, "Bad Array Terminator", [
|
|
124
|
+
"}"
|
|
125
|
+
]);
|
|
126
|
+
result.setInArray(false, idx);
|
|
127
|
+
break;
|
|
128
|
+
case "{":
|
|
129
|
+
result.finishElement(idx, "Bad Group Start", [
|
|
130
|
+
null,
|
|
131
|
+
"!",
|
|
132
|
+
".",
|
|
133
|
+
"[",
|
|
134
|
+
"{",
|
|
135
|
+
","
|
|
136
|
+
], {
|
|
137
|
+
group: true
|
|
138
|
+
});
|
|
139
|
+
result.startGroup();
|
|
140
|
+
break;
|
|
141
|
+
case ",":
|
|
142
|
+
result.finishElement(idx, "Bad Group Separator", [
|
|
143
|
+
"]",
|
|
144
|
+
"}"
|
|
145
|
+
]);
|
|
146
|
+
result.newGroupElement();
|
|
147
|
+
break;
|
|
148
|
+
case "}":
|
|
149
|
+
result.finishElement(idx, "Bad Group Terminator", [
|
|
150
|
+
"]",
|
|
151
|
+
"}"
|
|
152
|
+
]);
|
|
153
|
+
result.finishGroup(idx);
|
|
154
|
+
break;
|
|
155
|
+
case "!":
|
|
156
|
+
result.finishElement(idx, "Bad Exclusion", [
|
|
157
|
+
null,
|
|
158
|
+
".",
|
|
159
|
+
",",
|
|
160
|
+
"{",
|
|
161
|
+
"["
|
|
162
|
+
], {
|
|
163
|
+
finReq: true
|
|
164
|
+
});
|
|
165
|
+
result.startExclusion(idx);
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
switch(char){
|
|
172
|
+
case "(":
|
|
173
|
+
bracketDepth += 1;
|
|
174
|
+
break;
|
|
175
|
+
case ")":
|
|
176
|
+
if (bracketDepth === 0) {
|
|
177
|
+
throwError("Unexpected Parentheses", input, {
|
|
178
|
+
char: idx
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
bracketDepth -= 1;
|
|
182
|
+
break;
|
|
183
|
+
default:
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
escaped = char === "\\" ? !escaped : false;
|
|
188
|
+
}
|
|
189
|
+
if (escaped !== false) {
|
|
190
|
+
throwError("Dangling Escape", input, {
|
|
191
|
+
char: inputLength - 1
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (bracketDepth !== 0) {
|
|
195
|
+
throwError("Unterminated Parentheses", input);
|
|
196
|
+
}
|
|
197
|
+
result.finishElement(inputLength, "Bad Terminator", [
|
|
198
|
+
"]",
|
|
199
|
+
"}"
|
|
200
|
+
]);
|
|
201
|
+
return result.finalizeResult();
|
|
202
|
+
};
|
|
203
|
+
var _default = {
|
|
204
|
+
parse: parse
|
|
205
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _default = function(condition) {
|
|
12
|
+
var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Internal Logic Error";
|
|
13
|
+
if (!condition) {
|
|
14
|
+
throw new Error(typeof message === "function" ? message() : message);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
escape: function() {
|
|
13
|
+
return escape;
|
|
14
|
+
},
|
|
15
|
+
asRegex: function() {
|
|
16
|
+
return asRegex;
|
|
17
|
+
},
|
|
18
|
+
toPath: function() {
|
|
19
|
+
return toPath;
|
|
20
|
+
},
|
|
21
|
+
formatNeedle: function() {
|
|
22
|
+
return formatNeedle;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var specialChars = /[?!,.*+[\](){}\\]/g;
|
|
26
|
+
var escape = function(input) {
|
|
27
|
+
return input.replace(specialChars, "\\$&");
|
|
28
|
+
};
|
|
29
|
+
var regexMetaChars = /[\\^$*+?.()|[\]{}]/;
|
|
30
|
+
var asRegex = function(regexStr) {
|
|
31
|
+
var hasStart = regexStr.charCodeAt(0) === 94; // '^' is char code 94
|
|
32
|
+
var hasEnd = regexStr.charCodeAt(regexStr.length - 1) === 36; // '$' is char code 36
|
|
33
|
+
var content = regexStr.slice(hasStart ? 1 : 0, hasEnd ? -1 : undefined);
|
|
34
|
+
if (regexMetaChars.test(content)) {
|
|
35
|
+
try {
|
|
36
|
+
return new RegExp(regexStr);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new Error('Invalid Regex: "'.concat(regexStr, '"'));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (hasStart && hasEnd) {
|
|
42
|
+
return {
|
|
43
|
+
test: function(v) {
|
|
44
|
+
return String(v) === content;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (hasStart) {
|
|
49
|
+
return {
|
|
50
|
+
test: function(v) {
|
|
51
|
+
return String(v).startsWith(content);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (hasEnd) {
|
|
56
|
+
return {
|
|
57
|
+
test: function(v) {
|
|
58
|
+
return String(v).endsWith(content);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
test: function(v) {
|
|
64
|
+
return String(v).includes(content);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
var toPath = function(input) {
|
|
69
|
+
var result = "";
|
|
70
|
+
for(var i = 0, len = input.length; i < len; i += 1){
|
|
71
|
+
var char = input[i];
|
|
72
|
+
if (typeof char === "number") {
|
|
73
|
+
result += "[".concat(char, "]");
|
|
74
|
+
} else {
|
|
75
|
+
if (result.length > 0) {
|
|
76
|
+
result += ".";
|
|
77
|
+
}
|
|
78
|
+
result += escape(char);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
var formatNeedle = function(n) {
|
|
84
|
+
return Array.isArray(n) ? toPath(n) : n;
|
|
85
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _arrayLikeToArray(arr, len) {
|
|
12
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
13
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
14
|
+
return arr2;
|
|
15
|
+
}
|
|
16
|
+
function _arrayWithoutHoles(arr) {
|
|
17
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
18
|
+
}
|
|
19
|
+
function _iterableToArray(iter) {
|
|
20
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
21
|
+
}
|
|
22
|
+
function _nonIterableSpread() {
|
|
23
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
24
|
+
}
|
|
25
|
+
function _toConsumableArray(arr) {
|
|
26
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
27
|
+
}
|
|
28
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
29
|
+
if (!o) return;
|
|
30
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
31
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
32
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
33
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
34
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
35
|
+
}
|
|
36
|
+
var _default = function(tree, cb) {
|
|
37
|
+
var stack = [
|
|
38
|
+
tree
|
|
39
|
+
];
|
|
40
|
+
var parent = [
|
|
41
|
+
null
|
|
42
|
+
];
|
|
43
|
+
var count = [];
|
|
44
|
+
var depth = [];
|
|
45
|
+
var idx = 0;
|
|
46
|
+
var inc = true;
|
|
47
|
+
while(idx !== -1){
|
|
48
|
+
var e = stack[idx];
|
|
49
|
+
if (Array.isArray(e)) {
|
|
50
|
+
if (e.or !== true) {
|
|
51
|
+
var _stack, _parent;
|
|
52
|
+
(_stack = stack).splice.apply(_stack, [
|
|
53
|
+
idx,
|
|
54
|
+
1
|
|
55
|
+
].concat(_toConsumableArray(e)));
|
|
56
|
+
(_parent = parent).splice.apply(_parent, [
|
|
57
|
+
idx,
|
|
58
|
+
1
|
|
59
|
+
].concat(_toConsumableArray(new Array(e.length).fill(parent[idx]))));
|
|
60
|
+
if (parent[idx] !== null) {
|
|
61
|
+
depth[parent[idx]] += e.length - 1;
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
if (count[idx] === undefined) {
|
|
65
|
+
count[idx] = 0;
|
|
66
|
+
depth[idx] = 0;
|
|
67
|
+
} else if (depth[idx] !== 0) {
|
|
68
|
+
stack.splice(idx + 1, depth[idx]);
|
|
69
|
+
parent.splice(idx + 1, depth[idx]);
|
|
70
|
+
depth[idx] = 0;
|
|
71
|
+
}
|
|
72
|
+
if (count[idx] < e.length) {
|
|
73
|
+
stack.splice(idx + 1, 0, e[count[idx]]);
|
|
74
|
+
parent.splice(idx + 1, 0, idx);
|
|
75
|
+
count[idx] = (count[idx] || 0) + 1;
|
|
76
|
+
depth[idx] += 1;
|
|
77
|
+
inc = true;
|
|
78
|
+
idx += 1;
|
|
79
|
+
} else {
|
|
80
|
+
count[idx] = 0;
|
|
81
|
+
idx -= 1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else if (inc === true) {
|
|
85
|
+
cb("ADD", e);
|
|
86
|
+
if (idx === stack.length - 1) {
|
|
87
|
+
cb("FIN", e);
|
|
88
|
+
inc = false;
|
|
89
|
+
} else {
|
|
90
|
+
idx += 1;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
cb("RM", e);
|
|
94
|
+
idx -= 1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|