@schukai/monster 3.5.0 → 3.8.0
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/package.json +1 -1
- package/source/constants.mjs +4 -9
- package/source/constraints/abstract.mjs +4 -6
- package/source/constraints/abstractoperator.mjs +6 -12
- package/source/constraints/andoperator.mjs +3 -6
- package/source/constraints/invalid.mjs +3 -6
- package/source/constraints/isarray.mjs +6 -9
- package/source/constraints/isobject.mjs +4 -7
- package/source/constraints/namespace.mjs +1 -3
- package/source/constraints/oroperator.mjs +26 -25
- package/source/constraints/valid.mjs +3 -6
- package/source/data/buildmap.mjs +20 -36
- package/source/data/buildtree.mjs +29 -29
- package/source/data/datasource/namespace.mjs +1 -1
- package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
- package/source/data/datasource/server/restapi.mjs +51 -65
- package/source/data/datasource/server/webconnect.mjs +26 -35
- package/source/data/datasource/server.mjs +16 -20
- package/source/data/datasource/storage/localstorage.mjs +8 -11
- package/source/data/datasource/storage/sessionstorage.mjs +8 -10
- package/source/data/datasource/storage.mjs +18 -22
- package/source/data/datasource.mjs +27 -43
- package/source/data/diff.mjs +20 -32
- package/source/data/extend.mjs +20 -14
- package/source/data/namespace.mjs +1 -3
- package/source/data/pathfinder.mjs +105 -87
- package/source/data/pipe.mjs +6 -10
- package/source/data/transformer.mjs +141 -157
- package/source/dom/assembler.mjs +6 -9
- package/source/dom/attributes.mjs +36 -48
- package/source/dom/constants.mjs +55 -71
- package/source/dom/customcontrol.mjs +16 -21
- package/source/dom/customelement.mjs +140 -164
- package/source/dom/events.mjs +17 -24
- package/source/dom/focusmanager.mjs +31 -49
- package/source/dom/locale.mjs +18 -20
- package/source/dom/namespace.mjs +1 -1
- package/source/dom/ready.mjs +7 -10
- package/source/dom/resource/data.mjs +38 -46
- package/source/dom/resource/link/namespace.mjs +1 -3
- package/source/dom/resource/link/stylesheet.mjs +7 -11
- package/source/dom/resource/link.mjs +36 -17
- package/source/dom/resource/namespace.mjs +1 -1
- package/source/dom/resource/script.mjs +23 -13
- package/source/dom/resource.mjs +47 -60
- package/source/dom/resourcemanager.mjs +36 -43
- package/source/dom/template.mjs +17 -24
- package/source/dom/theme.mjs +8 -12
- package/source/dom/updater.mjs +150 -196
- package/source/dom/util.mjs +11 -12
- package/source/dom/worker/factory.mjs +21 -25
- package/source/dom/worker/namespace.mjs +1 -1
- package/source/i18n/formatter.mjs +20 -24
- package/source/i18n/locale.mjs +42 -55
- package/source/i18n/namespace.mjs +1 -1
- package/source/i18n/provider.mjs +4 -7
- package/source/i18n/providers/embed.mjs +16 -26
- package/source/i18n/providers/fetch.mjs +30 -36
- package/source/i18n/translations.mjs +17 -24
- package/source/logging/handler/console.mjs +6 -10
- package/source/logging/handler.mjs +15 -18
- package/source/logging/logentry.mjs +8 -9
- package/source/logging/logger.mjs +73 -55
- package/source/logging/namespace.mjs +1 -1
- package/source/math/namespace.mjs +1 -1
- package/source/math/random.mjs +13 -14
- package/source/monster.mjs +132 -100
- package/source/net/namespace.mjs +1 -3
- package/source/net/webconnect/message.mjs +6 -8
- package/source/net/webconnect/namespace.mjs +1 -3
- package/source/net/webconnect.mjs +28 -39
- package/source/text/formatter.mjs +44 -55
- package/source/types/base.mjs +16 -26
- package/source/types/basewithoptions.mjs +8 -14
- package/source/types/binary.mjs +4 -5
- package/source/types/dataurl.mjs +19 -27
- package/source/types/global.mjs +14 -26
- package/source/types/id.mjs +4 -6
- package/source/types/is.mjs +11 -16
- package/source/types/mediatype.mjs +29 -44
- package/source/types/namespace.mjs +0 -1
- package/source/types/node.mjs +16 -22
- package/source/types/nodelist.mjs +10 -14
- package/source/types/noderecursiveiterator.mjs +11 -14
- package/source/types/observablequeue.mjs +13 -16
- package/source/types/observer.mjs +16 -23
- package/source/types/observerlist.mjs +18 -21
- package/source/types/proxyobserver.mjs +24 -37
- package/source/types/queue.mjs +8 -13
- package/source/types/randomid.mjs +10 -10
- package/source/types/regex.mjs +3 -5
- package/source/types/stack.mjs +4 -8
- package/source/types/tokenlist.mjs +24 -31
- package/source/types/typeof.mjs +5 -7
- package/source/types/uniquequeue.mjs +8 -13
- package/source/types/uuid.mjs +18 -25
- package/source/types/validate.mjs +26 -27
- package/source/types/version.mjs +17 -25
- package/source/util/clone.mjs +23 -32
- package/source/util/comparator.mjs +7 -15
- package/source/util/deadmansswitch.mjs +16 -23
- package/source/util/freeze.mjs +5 -7
- package/source/util/namespace.mjs +1 -1
- package/source/util/processing.mjs +33 -39
- package/source/util/trimspaces.mjs +17 -24
- package/test/cases/monster.mjs +1 -1
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {Base} from
|
|
9
|
-
import {isArray, isInteger, isObject, isPrimitive} from
|
|
10
|
-
import {Stack} from "../types/stack.mjs";
|
|
11
|
-
import {validateInteger, validateString} from
|
|
8
|
+
import { Base } from "../types/base.mjs";
|
|
9
|
+
import { isArray, isInteger, isObject, isPrimitive, isString } from "../types/is.mjs";
|
|
10
|
+
import { Stack } from "../types/stack.mjs";
|
|
11
|
+
import { validateInteger, validateBoolean, validateString } from "../types/validate.mjs";
|
|
12
12
|
|
|
13
|
-
export {Pathfinder, DELIMITER, WILDCARD}
|
|
13
|
+
export { Pathfinder, DELIMITER, WILDCARD };
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* path separator
|
|
@@ -18,13 +18,13 @@ export {Pathfinder, DELIMITER, WILDCARD}
|
|
|
18
18
|
* @private
|
|
19
19
|
* @type {string}
|
|
20
20
|
*/
|
|
21
|
-
const DELIMITER =
|
|
21
|
+
const DELIMITER = ".";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @private
|
|
25
25
|
* @type {string}
|
|
26
26
|
*/
|
|
27
|
-
const WILDCARD =
|
|
27
|
+
const WILDCARD = "*";
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Pathfinder is a class to find a path to an object.
|
|
@@ -72,7 +72,6 @@ const WILDCARD = '*';
|
|
|
72
72
|
* @memberOf Monster.Data
|
|
73
73
|
*/
|
|
74
74
|
class Pathfinder extends Base {
|
|
75
|
-
|
|
76
75
|
/**
|
|
77
76
|
* @param {array|object|Map|Set} value
|
|
78
77
|
* @since 1.4.0
|
|
@@ -82,7 +81,7 @@ class Pathfinder extends Base {
|
|
|
82
81
|
super();
|
|
83
82
|
|
|
84
83
|
if (isPrimitive(object)) {
|
|
85
|
-
throw new Error(
|
|
84
|
+
throw new Error("the parameter must not be a simple type");
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
this.object = object;
|
|
@@ -104,7 +103,7 @@ class Pathfinder extends Base {
|
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
105
|
*
|
|
107
|
-
* @param {string} path
|
|
106
|
+
* @param {string|array} path
|
|
108
107
|
* @since 1.4.0
|
|
109
108
|
* @returns {*}
|
|
110
109
|
* @throws {TypeError} unsupported type
|
|
@@ -114,12 +113,12 @@ class Pathfinder extends Base {
|
|
|
114
113
|
* @throws {Error} unsupported action for this data type
|
|
115
114
|
*/
|
|
116
115
|
getVia(path) {
|
|
117
|
-
return getValueViaPath.call(this, this.object,
|
|
116
|
+
return getValueViaPath.call(this, this.object, path);
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
/**
|
|
121
120
|
*
|
|
122
|
-
* @param {string} path
|
|
121
|
+
* @param {string|array} path
|
|
123
122
|
* @param {*} value
|
|
124
123
|
* @returns {Pathfinder}
|
|
125
124
|
* @since 1.4.0
|
|
@@ -129,7 +128,6 @@ class Pathfinder extends Base {
|
|
|
129
128
|
* @throws {Error} unsupported action for this data type
|
|
130
129
|
*/
|
|
131
130
|
setVia(path, value) {
|
|
132
|
-
validateString(path);
|
|
133
131
|
setValueViaPath.call(this, this.object, path, value);
|
|
134
132
|
return this;
|
|
135
133
|
}
|
|
@@ -137,7 +135,7 @@ class Pathfinder extends Base {
|
|
|
137
135
|
/**
|
|
138
136
|
* Delete Via Path
|
|
139
137
|
*
|
|
140
|
-
* @param {string} path
|
|
138
|
+
* @param {string|array} path
|
|
141
139
|
* @returns {Pathfinder}
|
|
142
140
|
* @since 1.6.0
|
|
143
141
|
* @throws {TypeError} unsupported type
|
|
@@ -146,14 +144,13 @@ class Pathfinder extends Base {
|
|
|
146
144
|
* @throws {Error} unsupported action for this data type
|
|
147
145
|
*/
|
|
148
146
|
deleteVia(path) {
|
|
149
|
-
validateString(path);
|
|
150
147
|
deleteValueViaPath.call(this, this.object, path);
|
|
151
148
|
return this;
|
|
152
149
|
}
|
|
153
150
|
|
|
154
151
|
/**
|
|
155
152
|
*
|
|
156
|
-
* @param {string} path
|
|
153
|
+
* @param {string|array} path
|
|
157
154
|
* @return {bool}
|
|
158
155
|
* @throws {TypeError} unsupported type
|
|
159
156
|
* @throws {TypeError} value is not a string
|
|
@@ -161,25 +158,20 @@ class Pathfinder extends Base {
|
|
|
161
158
|
* @since 1.4.0
|
|
162
159
|
*/
|
|
163
160
|
exists(path) {
|
|
164
|
-
validateString(path);
|
|
165
161
|
try {
|
|
166
162
|
getValueViaPath.call(this, this.object, path, true);
|
|
167
163
|
return true;
|
|
168
|
-
} catch (e) {
|
|
169
|
-
|
|
170
|
-
}
|
|
164
|
+
} catch (e) {}
|
|
171
165
|
|
|
172
166
|
return false;
|
|
173
167
|
}
|
|
174
|
-
|
|
175
168
|
}
|
|
176
169
|
|
|
177
|
-
|
|
178
170
|
/**
|
|
179
171
|
*
|
|
180
172
|
* @param {*} subject
|
|
181
|
-
* @param {string} path
|
|
182
|
-
* @param {
|
|
173
|
+
* @param {string|array} path
|
|
174
|
+
* @param {boolean} check
|
|
183
175
|
* @return {Map}
|
|
184
176
|
* @throws {TypeError} unsupported type
|
|
185
177
|
* @throws {Error} the journey is not at its end
|
|
@@ -187,12 +179,20 @@ class Pathfinder extends Base {
|
|
|
187
179
|
* @private
|
|
188
180
|
*/
|
|
189
181
|
function iterate(subject, path, check) {
|
|
182
|
+
if (check === undefined) {
|
|
183
|
+
check = false;
|
|
184
|
+
}
|
|
185
|
+
validateBoolean(check);
|
|
190
186
|
|
|
191
|
-
const result = new Map;
|
|
187
|
+
const result = new Map();
|
|
188
|
+
|
|
189
|
+
if (isArray(path)) {
|
|
190
|
+
path = path.join(DELIMITER);
|
|
191
|
+
}
|
|
192
192
|
|
|
193
193
|
if (isObject(subject) || isArray(subject)) {
|
|
194
194
|
for (const [key, value] of Object.entries(subject)) {
|
|
195
|
-
result.set(key, getValueViaPath.call(this, value, path, check))
|
|
195
|
+
result.set(key, getValueViaPath.call(this, value, path, check));
|
|
196
196
|
}
|
|
197
197
|
} else {
|
|
198
198
|
let key = path.split(DELIMITER).shift();
|
|
@@ -200,15 +200,13 @@ function iterate(subject, path, check) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
return result;
|
|
203
|
-
|
|
204
|
-
|
|
205
203
|
}
|
|
206
204
|
|
|
207
205
|
/**
|
|
208
206
|
*
|
|
209
207
|
* @param {*} subject
|
|
210
|
-
* @param [string} path
|
|
211
|
-
* @param [boolean} check
|
|
208
|
+
* @param [string|array} path
|
|
209
|
+
* @param [boolean} check
|
|
212
210
|
* @returns {*}
|
|
213
211
|
* @throws {TypeError} unsupported type
|
|
214
212
|
* @throws {Error} the journey is not at its end
|
|
@@ -216,12 +214,24 @@ function iterate(subject, path, check) {
|
|
|
216
214
|
* @private
|
|
217
215
|
*/
|
|
218
216
|
function getValueViaPath(subject, path, check) {
|
|
217
|
+
if (check === undefined) {
|
|
218
|
+
check = false;
|
|
219
|
+
}
|
|
220
|
+
validateBoolean(check);
|
|
219
221
|
|
|
220
|
-
if (path
|
|
221
|
-
|
|
222
|
+
if (!(isArray(path) || isString(path))) {
|
|
223
|
+
throw new Error("type error: path must be a string or an array");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let parts;
|
|
227
|
+
if (isString(path)) {
|
|
228
|
+
if (path === "") {
|
|
229
|
+
return subject;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
parts = path.split(DELIMITER);
|
|
222
233
|
}
|
|
223
234
|
|
|
224
|
-
let parts = path.split(DELIMITER)
|
|
225
235
|
let current = parts.shift();
|
|
226
236
|
|
|
227
237
|
if (current === this.wildCard) {
|
|
@@ -229,58 +239,50 @@ function getValueViaPath(subject, path, check) {
|
|
|
229
239
|
}
|
|
230
240
|
|
|
231
241
|
if (isObject(subject) || isArray(subject)) {
|
|
232
|
-
|
|
233
242
|
let anchor;
|
|
234
243
|
if (subject instanceof Map || subject instanceof WeakMap) {
|
|
235
244
|
anchor = subject.get(current);
|
|
236
|
-
|
|
237
245
|
} else if (subject instanceof Set || subject instanceof WeakSet) {
|
|
238
246
|
current = parseInt(current);
|
|
239
|
-
validateInteger(current)
|
|
247
|
+
validateInteger(current);
|
|
240
248
|
anchor = [...subject]?.[current];
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
throw Error('unsupported action for this data type');
|
|
244
|
-
|
|
249
|
+
} else if (typeof WeakRef === "function" && subject instanceof WeakRef) {
|
|
250
|
+
throw Error("unsupported action for this data type");
|
|
245
251
|
} else if (isArray(subject)) {
|
|
246
252
|
current = parseInt(current);
|
|
247
|
-
validateInteger(current)
|
|
253
|
+
validateInteger(current);
|
|
248
254
|
anchor = subject?.[current];
|
|
249
255
|
} else {
|
|
250
256
|
anchor = subject?.[current];
|
|
251
257
|
}
|
|
252
258
|
|
|
253
259
|
if (isObject(anchor) || isArray(anchor)) {
|
|
254
|
-
return getValueViaPath.call(this, anchor, parts.join(DELIMITER), check)
|
|
260
|
+
return getValueViaPath.call(this, anchor, parts.join(DELIMITER), check);
|
|
255
261
|
}
|
|
256
262
|
|
|
257
263
|
if (parts.length > 0) {
|
|
258
|
-
throw Error(
|
|
264
|
+
throw Error(`the journey is not at its end (${parts.join(DELIMITER)})`);
|
|
259
265
|
}
|
|
260
266
|
|
|
261
|
-
|
|
262
267
|
if (check === true) {
|
|
263
268
|
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(subject), current);
|
|
264
269
|
|
|
265
270
|
if (!subject.hasOwnProperty(current) && descriptor === undefined) {
|
|
266
|
-
throw Error(
|
|
271
|
+
throw Error("unknown value");
|
|
267
272
|
}
|
|
268
|
-
|
|
269
273
|
}
|
|
270
274
|
|
|
271
275
|
return anchor;
|
|
272
|
-
|
|
273
276
|
}
|
|
274
277
|
|
|
275
|
-
throw TypeError(
|
|
276
|
-
|
|
278
|
+
throw TypeError(`unsupported type ${typeof subject}`);
|
|
277
279
|
}
|
|
278
280
|
|
|
279
281
|
/**
|
|
280
282
|
*
|
|
281
|
-
* @param object
|
|
282
|
-
* @param path
|
|
283
|
-
* @param value
|
|
283
|
+
* @param {object} subject
|
|
284
|
+
* @param {string|array} path
|
|
285
|
+
* @param {*} value
|
|
284
286
|
* @returns {void}
|
|
285
287
|
* @throws {TypeError} unsupported type
|
|
286
288
|
* @throws {TypeError} unsupported type
|
|
@@ -288,24 +290,32 @@ function getValueViaPath(subject, path, check) {
|
|
|
288
290
|
* @throws {Error} unsupported action for this data type
|
|
289
291
|
* @private
|
|
290
292
|
*/
|
|
291
|
-
function setValueViaPath(
|
|
293
|
+
function setValueViaPath(subject, path, value) {
|
|
294
|
+
if (!(isArray(path) || isString(path))) {
|
|
295
|
+
throw new Error("type error: path must be a string or an array");
|
|
296
|
+
}
|
|
292
297
|
|
|
293
|
-
|
|
298
|
+
let parts;
|
|
299
|
+
if (isArray(path)) {
|
|
300
|
+
if (path.length === 0) {
|
|
301
|
+
return subject;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
parts = path;
|
|
305
|
+
} else {
|
|
306
|
+
parts = path.split(DELIMITER);
|
|
307
|
+
}
|
|
294
308
|
|
|
295
|
-
let parts = path.split(DELIMITER)
|
|
296
309
|
let last = parts.pop();
|
|
297
310
|
let subpath = parts.join(DELIMITER);
|
|
298
311
|
|
|
299
|
-
let stack = new Stack()
|
|
312
|
+
let stack = new Stack();
|
|
300
313
|
let current = subpath;
|
|
301
314
|
while (true) {
|
|
302
|
-
|
|
303
315
|
try {
|
|
304
|
-
getValueViaPath.call(this,
|
|
316
|
+
getValueViaPath.call(this, subject, current, true);
|
|
305
317
|
break;
|
|
306
|
-
} catch (e) {
|
|
307
|
-
|
|
308
|
-
}
|
|
318
|
+
} catch (e) {}
|
|
309
319
|
|
|
310
320
|
stack.push(current);
|
|
311
321
|
parts.pop();
|
|
@@ -323,35 +333,30 @@ function setValueViaPath(object, path, value) {
|
|
|
323
333
|
if (isInteger(parseInt(n))) {
|
|
324
334
|
obj = [];
|
|
325
335
|
}
|
|
326
|
-
|
|
327
336
|
}
|
|
328
337
|
|
|
329
|
-
setValueViaPath.call(this,
|
|
338
|
+
setValueViaPath.call(this, subject, current, obj);
|
|
330
339
|
}
|
|
331
340
|
|
|
332
|
-
let anchor = getValueViaPath.call(this,
|
|
341
|
+
let anchor = getValueViaPath.call(this, subject, subpath);
|
|
333
342
|
|
|
334
|
-
if (!isObject(
|
|
335
|
-
throw TypeError(
|
|
343
|
+
if (!(isObject(subject) || isArray(subject))) {
|
|
344
|
+
throw TypeError(`unsupported type: ${typeof subject}`);
|
|
336
345
|
}
|
|
337
346
|
|
|
338
347
|
if (anchor instanceof Map || anchor instanceof WeakMap) {
|
|
339
348
|
anchor.set(last, value);
|
|
340
349
|
} else if (anchor instanceof Set || anchor instanceof WeakSet) {
|
|
341
|
-
anchor.append(value)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
throw Error('unsupported action for this data type');
|
|
345
|
-
|
|
350
|
+
anchor.append(value);
|
|
351
|
+
} else if (typeof WeakRef === "function" && anchor instanceof WeakRef) {
|
|
352
|
+
throw Error("unsupported action for this data type");
|
|
346
353
|
} else if (isArray(anchor)) {
|
|
347
354
|
last = parseInt(last);
|
|
348
|
-
validateInteger(last)
|
|
355
|
+
validateInteger(last);
|
|
349
356
|
assignProperty(anchor, last, value);
|
|
350
357
|
} else {
|
|
351
358
|
assignProperty(anchor, last, value);
|
|
352
359
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
360
|
}
|
|
356
361
|
|
|
357
362
|
/**
|
|
@@ -361,7 +366,6 @@ function setValueViaPath(object, path, value) {
|
|
|
361
366
|
* @param {*} value
|
|
362
367
|
*/
|
|
363
368
|
function assignProperty(object, key, value) {
|
|
364
|
-
|
|
365
369
|
if (!object.hasOwnProperty(key)) {
|
|
366
370
|
object[key] = value;
|
|
367
371
|
return;
|
|
@@ -372,13 +376,12 @@ function assignProperty(object, key, value) {
|
|
|
372
376
|
}
|
|
373
377
|
|
|
374
378
|
object[key] = value;
|
|
375
|
-
|
|
376
379
|
}
|
|
377
380
|
|
|
378
381
|
/**
|
|
379
382
|
*
|
|
380
|
-
* @param object
|
|
381
|
-
* @param path
|
|
383
|
+
* @param {object} subject
|
|
384
|
+
* @param {string} path
|
|
382
385
|
* @returns {void}
|
|
383
386
|
* @throws {TypeError} unsupported type
|
|
384
387
|
* @throws {TypeError} unsupported type
|
|
@@ -388,26 +391,41 @@ function assignProperty(object, key, value) {
|
|
|
388
391
|
* @since 1.6.0
|
|
389
392
|
* @private
|
|
390
393
|
*/
|
|
391
|
-
function deleteValueViaPath(
|
|
394
|
+
function deleteValueViaPath(subject, path) {
|
|
395
|
+
if (!(isArray(path) || isString(path))) {
|
|
396
|
+
throw new Error("type error: path must be a string or an array");
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
let parts;
|
|
400
|
+
if (isArray(path)) {
|
|
401
|
+
if (path.length === 0) {
|
|
402
|
+
return subject;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
parts = path;
|
|
406
|
+
} else {
|
|
407
|
+
parts = path.split(DELIMITER);
|
|
408
|
+
}
|
|
392
409
|
|
|
393
|
-
const parts = path.split(DELIMITER)
|
|
394
410
|
let last = parts.pop();
|
|
395
411
|
const subpath = parts.join(DELIMITER);
|
|
396
412
|
|
|
397
|
-
const anchor = getValueViaPath.call(this,
|
|
413
|
+
const anchor = getValueViaPath.call(this, subject, subpath);
|
|
398
414
|
|
|
399
415
|
if (anchor instanceof Map) {
|
|
400
416
|
anchor.delete(last);
|
|
401
|
-
} else if (
|
|
402
|
-
|
|
403
|
-
|
|
417
|
+
} else if (
|
|
418
|
+
anchor instanceof Set ||
|
|
419
|
+
anchor instanceof WeakMap ||
|
|
420
|
+
anchor instanceof WeakSet ||
|
|
421
|
+
(typeof WeakRef === "function" && anchor instanceof WeakRef)
|
|
422
|
+
) {
|
|
423
|
+
throw Error("unsupported action for this data type");
|
|
404
424
|
} else if (isArray(anchor)) {
|
|
405
425
|
last = parseInt(last);
|
|
406
|
-
validateInteger(last)
|
|
426
|
+
validateInteger(last);
|
|
407
427
|
delete anchor[last];
|
|
408
428
|
} else {
|
|
409
429
|
delete anchor[last];
|
|
410
430
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
431
|
}
|
package/source/data/pipe.mjs
CHANGED
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {Base} from
|
|
9
|
-
import {validateString} from
|
|
10
|
-
import {Transformer} from
|
|
8
|
+
import { Base } from "../types/base.mjs";
|
|
9
|
+
import { validateString } from "../types/validate.mjs";
|
|
10
|
+
import { Transformer } from "./transformer.mjs";
|
|
11
11
|
|
|
12
|
-
export {Pipe}
|
|
12
|
+
export { Pipe };
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @private
|
|
16
16
|
* @type {string}
|
|
17
17
|
*/
|
|
18
|
-
const DELIMITER =
|
|
18
|
+
const DELIMITER = "|";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* The pipe class makes it possible to combine several processing steps.
|
|
@@ -32,7 +32,6 @@ const DELIMITER = '|';
|
|
|
32
32
|
* @memberOf Monster.Data
|
|
33
33
|
*/
|
|
34
34
|
class Pipe extends Base {
|
|
35
|
-
|
|
36
35
|
/**
|
|
37
36
|
* @param {string} pipe a pipe consists of commands whose input and output are connected with the pipe symbol `|`.
|
|
38
37
|
* @throws {TypeError}
|
|
@@ -40,12 +39,10 @@ class Pipe extends Base {
|
|
|
40
39
|
constructor(pipe) {
|
|
41
40
|
super();
|
|
42
41
|
validateString(pipe);
|
|
43
|
-
|
|
42
|
+
|
|
44
43
|
this.pipe = pipe.split(DELIMITER).map((v) => {
|
|
45
44
|
return new Transformer(v);
|
|
46
45
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
/**
|
|
@@ -57,7 +54,6 @@ class Pipe extends Base {
|
|
|
57
54
|
* @throws {TypeError} value is not a function
|
|
58
55
|
*/
|
|
59
56
|
setCallback(name, callback, context) {
|
|
60
|
-
|
|
61
57
|
for (const [, t] of Object.entries(this.pipe)) {
|
|
62
58
|
t.setCallback(name, callback, context);
|
|
63
59
|
}
|