@schukai/monster 1.15.5 → 1.17.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +25 -0
- package/README.md +4 -4
- package/dist/modules/constants.js +1 -1
- package/dist/modules/constraints/abstract.js +1 -1
- package/dist/modules/constraints/abstractoperator.js +1 -1
- package/dist/modules/constraints/andoperator.js +1 -1
- package/dist/modules/constraints/invalid.js +1 -1
- package/dist/modules/constraints/isarray.js +1 -1
- package/dist/modules/constraints/isobject.js +1 -1
- package/dist/modules/constraints/namespace.js +2 -2
- package/dist/modules/constraints/oroperator.js +1 -1
- package/dist/modules/constraints/valid.js +1 -1
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/diff.js +2 -2
- package/dist/modules/data/extend.js +1 -1
- package/dist/modules/data/namespace.js +2 -2
- package/dist/modules/data/pathfinder.js +2 -2
- package/dist/modules/data/pipe.js +1 -1
- package/dist/modules/data/transformer.js +1 -1
- package/dist/modules/dom/assembler.js +1 -1
- package/dist/modules/dom/attributes.js +1 -1
- package/dist/modules/dom/constants.js +1 -1
- package/dist/modules/dom/customcontrol.js +1 -1
- package/dist/modules/dom/customelement.js +1 -1
- package/dist/modules/dom/events.js +1 -1
- package/dist/modules/dom/locale.js +1 -1
- package/dist/modules/dom/namespace.js +2 -2
- package/dist/modules/dom/template.js +1 -1
- package/dist/modules/dom/theme.js +1 -1
- package/dist/modules/dom/updater.js +1 -1
- package/dist/modules/dom/util.js +1 -1
- package/dist/modules/i18n/locale.js +1 -1
- package/dist/modules/i18n/namespace.js +2 -2
- package/dist/modules/i18n/provider.js +1 -1
- package/dist/modules/i18n/providers/fetch.js +1 -1
- package/dist/modules/i18n/providers/namespace.js +2 -2
- package/dist/modules/i18n/translations.js +1 -1
- package/dist/modules/logging/handler/console.js +2 -2
- package/dist/modules/logging/handler/namespace.js +2 -2
- package/dist/modules/logging/handler.js +1 -1
- package/dist/modules/logging/logentry.js +1 -1
- package/dist/modules/logging/logger.js +1 -1
- package/dist/modules/logging/namespace.js +2 -2
- package/dist/modules/math/namespace.js +2 -2
- package/dist/modules/math/random.js +1 -1
- package/dist/modules/monster.js +1 -1
- package/dist/modules/namespace.js +1 -1
- package/dist/modules/text/formatter.js +1 -1
- package/dist/modules/text/namespace.js +2 -2
- package/dist/modules/types/base.js +1 -1
- package/dist/modules/types/basewithoptions.js +1 -1
- package/dist/modules/types/global.js +1 -1
- package/dist/modules/types/id.js +1 -1
- package/dist/modules/types/is.js +1 -1
- package/dist/modules/types/namespace.js +2 -2
- package/dist/modules/types/observer.js +1 -1
- package/dist/modules/types/observerlist.js +1 -1
- package/dist/modules/types/proxyobserver.js +1 -1
- package/dist/modules/types/queue.js +1 -1
- package/dist/modules/types/randomid.js +1 -1
- package/dist/modules/types/stack.js +1 -1
- package/dist/modules/types/tokenlist.js +1 -1
- package/dist/modules/types/typeof.js +1 -1
- package/dist/modules/types/uniquequeue.js +1 -1
- package/dist/modules/types/validate.js +1 -1
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +1 -1
- package/dist/modules/util/comparator.js +1 -1
- package/dist/modules/util/freeze.js +1 -1
- package/dist/modules/util/namespace.js +2 -2
- package/dist/monster.dev.js +1293 -943
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -2
- package/package.json +1 -1
- package/source/constraints/abstract.js +1 -1
- package/source/constraints/abstractoperator.js +1 -1
- package/source/constraints/andoperator.js +6 -6
- package/source/constraints/invalid.js +4 -4
- package/source/constraints/isarray.js +4 -4
- package/source/constraints/isobject.js +4 -4
- package/source/constraints/namespace.js +3 -2
- package/source/constraints/oroperator.js +6 -6
- package/source/constraints/valid.js +4 -4
- package/source/data/buildmap.js +245 -12
- package/source/data/diff.js +7 -6
- package/source/data/extend.js +3 -3
- package/source/data/namespace.js +3 -2
- package/source/data/pathfinder.js +15 -11
- package/source/data/pipe.js +4 -4
- package/source/data/transformer.js +4 -4
- package/source/dom/assembler.js +4 -4
- package/source/dom/attributes.js +36 -46
- package/source/dom/constants.js +16 -14
- package/source/dom/customcontrol.js +12 -8
- package/source/dom/customelement.js +24 -11
- package/source/dom/events.js +6 -6
- package/source/dom/locale.js +5 -4
- package/source/dom/namespace.js +3 -2
- package/source/dom/template.js +6 -6
- package/source/dom/theme.js +5 -4
- package/source/dom/updater.js +11 -5
- package/source/dom/util.js +9 -9
- package/source/i18n/locale.js +27 -15
- package/source/i18n/namespace.js +3 -2
- package/source/i18n/provider.js +3 -3
- package/source/i18n/providers/fetch.js +22 -6
- package/source/i18n/providers/namespace.js +3 -2
- package/source/i18n/translations.js +3 -3
- package/source/logging/handler/console.js +34 -10
- package/source/logging/handler/namespace.js +3 -2
- package/source/logging/handler.js +4 -4
- package/source/logging/logentry.js +5 -5
- package/source/logging/logger.js +13 -13
- package/source/logging/namespace.js +3 -2
- package/source/math/namespace.js +3 -2
- package/source/math/random.js +3 -3
- package/source/namespace.js +1 -1
- package/source/text/formatter.js +3 -3
- package/source/text/namespace.js +3 -2
- package/source/types/base.js +3 -3
- package/source/types/basewithoptions.js +3 -3
- package/source/types/global.js +7 -7
- package/source/types/id.js +3 -3
- package/source/types/is.js +30 -30
- package/source/types/namespace.js +3 -2
- package/source/types/observer.js +4 -4
- package/source/types/observerlist.js +3 -3
- package/source/types/proxyobserver.js +6 -6
- package/source/types/queue.js +4 -4
- package/source/types/randomid.js +3 -3
- package/source/types/stack.js +3 -3
- package/source/types/tokenlist.js +3 -3
- package/source/types/typeof.js +4 -4
- package/source/types/uniquequeue.js +3 -3
- package/source/types/validate.js +34 -34
- package/source/types/version.js +7 -7
- package/source/util/clone.js +3 -3
- package/source/util/comparator.js +37 -7
- package/source/util/freeze.js +4 -4
- package/source/util/namespace.js +3 -2
- package/test/cases/data/buildmap.js +242 -16
- package/test/cases/data/diff.js +36 -3
- package/test/cases/data/pathfinder.js +298 -196
- package/test/cases/logging/handler/console.js +20 -0
- package/test/cases/monster.js +1 -1
- package/test/web/import.js +1 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +2 -2
- package/test/web/tests.js +3 -3
@@ -1,292 +1,394 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import {Pathfinder} from "../../../source/data/pathfinder.js";
|
4
3
|
import {expect} from "chai"
|
4
|
+
import {Pathfinder} from "../../../source/data/pathfinder.js";
|
5
5
|
|
6
6
|
describe('Pathfinder', function () {
|
7
7
|
|
8
|
-
let
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
]
|
18
|
-
d: undefined,
|
19
|
-
e: false,
|
20
|
-
f: [
|
21
|
-
{
|
22
|
-
g: false,
|
23
|
-
h: 3,
|
24
|
-
i: ["test2"]
|
25
|
-
}
|
26
|
-
],
|
27
|
-
j: {},
|
28
|
-
k: (new Map).set('m', {n: 3}),
|
29
|
-
l: (new Set).add({n: 4})
|
8
|
+
let convertMapResult = function (r) {
|
9
|
+
if (r instanceof Map) {
|
10
|
+
r = Object.fromEntries(r);
|
11
|
+
if (r instanceof Array) {
|
12
|
+
r = r.map((e) => {
|
13
|
+
return convertMapResult(e);
|
14
|
+
})
|
15
|
+
} else if (typeof r === "object") {
|
16
|
+
for (const [k, o] of Object.entries(r)) {
|
17
|
+
r[k] = convertMapResult(o);
|
30
18
|
}
|
31
19
|
}
|
32
|
-
}
|
20
|
+
}
|
33
21
|
|
34
|
-
|
22
|
+
return r;
|
23
|
+
}
|
35
24
|
|
36
25
|
|
37
|
-
|
38
|
-
|
39
|
-
describe('.setVia(x)', function () {
|
40
|
-
|
26
|
+
describe('with Wildcard and Iterations', function () {
|
41
27
|
let pf, obj;
|
42
28
|
|
43
29
|
beforeEach(function () {
|
44
|
-
obj = {
|
30
|
+
obj = {
|
31
|
+
a: [
|
32
|
+
{
|
33
|
+
b: [
|
34
|
+
{
|
35
|
+
c: "1-1"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
c: "1-2"
|
39
|
+
}
|
40
|
+
],
|
41
|
+
d: '!'
|
42
|
+
|
43
|
+
},
|
44
|
+
{
|
45
|
+
b: [
|
46
|
+
{
|
47
|
+
c: "2-1"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
c: "2-2"
|
51
|
+
}
|
52
|
+
],
|
53
|
+
d: '?'
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
45
57
|
pf = new Pathfinder(obj);
|
46
58
|
});
|
47
59
|
|
48
60
|
[
|
49
|
-
['a
|
50
|
-
['a
|
51
|
-
['a.b
|
52
|
-
['a.b
|
61
|
+
['a.*.b.*', '{"0":{"0":{"c":"1-1"},"1":{"c":"1-2"}},"1":{"0":{"c":"2-1"},"1":{"c":"2-2"}}}'],
|
62
|
+
['a.*.b', '{"0":[{"c":"1-1"},{"c":"1-2"}],"1":[{"c":"2-1"},{"c":"2-2"}]}'],
|
63
|
+
['a.1.b', '[{"c":"2-1"},{"c":"2-2"}]'],
|
64
|
+
['a.0.b', '[{"c":"1-1"},{"c":"1-2"}]'],
|
53
65
|
].forEach(function (data) {
|
54
66
|
|
55
67
|
let a = data.shift()
|
56
68
|
let b = data.shift()
|
57
|
-
let c = data.shift()
|
58
69
|
|
59
70
|
|
60
|
-
it('.setVia(' + a + '
|
61
|
-
pf.
|
62
|
-
|
71
|
+
it('.setVia(' + a + ') should result in ' + b, function () {
|
72
|
+
let r = pf.getVia(a);
|
73
|
+
let i = convertMapResult(r);
|
74
|
+
expect(JSON.stringify(i)).is.equal(b);
|
63
75
|
});
|
64
76
|
|
65
77
|
|
66
78
|
});
|
67
79
|
|
68
|
-
})
|
69
80
|
|
70
|
-
|
81
|
+
});
|
71
82
|
|
72
|
-
let a;
|
73
|
-
let b;
|
74
|
-
let c;
|
75
83
|
|
76
|
-
|
77
|
-
a = "a.x";
|
78
|
-
b = "true";
|
79
|
-
c = "a.y.d";
|
80
|
-
})
|
84
|
+
describe('api tests', function () {
|
81
85
|
|
82
|
-
|
83
|
-
expect(pathfinder.setVia(a, b)).is.instanceOf(Pathfinder);
|
84
|
-
});
|
86
|
+
let pathfinder, object;
|
85
87
|
|
86
|
-
|
87
|
-
pathfinder.setVia(a, b);
|
88
|
-
expect(JSON.stringify(object)).is.equal('{"a":{"b":{"c":[4,"test1",false,null,null],"e":false,"f":[{"g":false,"h":3,"i":["test2"]}],"j":{},"k":{},"l":{}},"x":"true"}}');
|
89
|
-
});
|
88
|
+
beforeEach(() => {
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
object = {
|
91
|
+
a: {
|
92
|
+
b: {
|
93
|
+
c: [
|
94
|
+
4, "test1", false, undefined, parseInt("a")
|
95
|
+
],
|
96
|
+
d: undefined,
|
97
|
+
e: false,
|
98
|
+
f: [
|
99
|
+
{
|
100
|
+
g: false,
|
101
|
+
h: 3,
|
102
|
+
i: ["test2"]
|
103
|
+
}
|
104
|
+
],
|
105
|
+
j: {},
|
106
|
+
k: (new Map).set('m', {n: 3}),
|
107
|
+
l: (new Set).add({n: 4})
|
108
|
+
}
|
109
|
+
}
|
110
|
+
};
|
95
111
|
|
96
|
-
|
112
|
+
pathfinder = new Pathfinder(object);
|
97
113
|
|
98
114
|
|
99
|
-
|
115
|
+
});
|
100
116
|
|
117
|
+
describe('create new object', function () {
|
101
118
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
['a.b.d', true],
|
109
|
-
['a.b.f.0.g', true],
|
110
|
-
['a.b.f.0.i.0', true],
|
111
|
-
['a.b.f.0.i.2', false],
|
112
|
-
['a.b.e', true],
|
113
|
-
].forEach(function (data) {
|
119
|
+
[
|
120
|
+
[12],
|
121
|
+
[undefined],
|
122
|
+
[null],
|
123
|
+
["test"]
|
124
|
+
].forEach(function (data) {
|
114
125
|
|
115
|
-
|
116
|
-
|
126
|
+
let a = data.shift()
|
127
|
+
let label = typeof a;
|
128
|
+
if (a === null) label = 'null';
|
117
129
|
|
118
130
|
|
119
|
-
|
120
|
-
|
131
|
+
it(label + ' should throw error', function () {
|
132
|
+
|
133
|
+
expect(() => {
|
134
|
+
new Pathfinder(a)
|
135
|
+
}).to.throw(Error)
|
136
|
+
});
|
121
137
|
});
|
138
|
+
})
|
122
139
|
|
140
|
+
describe('.setVia(x)', function () {
|
123
141
|
|
124
|
-
|
142
|
+
let pf, obj;
|
125
143
|
|
126
|
-
|
144
|
+
beforeEach(function () {
|
145
|
+
obj = {}
|
146
|
+
pf = new Pathfinder(obj);
|
147
|
+
});
|
127
148
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
149
|
+
[
|
150
|
+
['a.b.0.0.c', true, '{"a":{"b":[[{"c":true}]]}}'],
|
151
|
+
['a.b.0.c', true, '{"a":{"b":[{"c":true}]}}'],
|
152
|
+
['a.b.3.c', true, '{"a":{"b":[null,null,null,{"c":true}]}}'],
|
153
|
+
['a.b.c', true, '{"a":{"b":{"c":true}}}']
|
154
|
+
].forEach(function (data) {
|
133
155
|
|
134
|
-
|
156
|
+
let a = data.shift()
|
157
|
+
let b = data.shift()
|
158
|
+
let c = data.shift()
|
159
|
+
|
160
|
+
|
161
|
+
it('.setVia(' + a + ', ' + b + ') should result in ' + c, function () {
|
162
|
+
pf.setVia(a, b)
|
163
|
+
expect(JSON.stringify(obj)).is.equal(c);
|
164
|
+
});
|
135
165
|
|
136
|
-
let a = data.shift()
|
137
|
-
let b = data.shift()
|
138
166
|
|
139
|
-
it('.deleteVia(' + a + ') should return ' + b + ' ', function () {
|
140
|
-
pathfinder.deleteVia(a)
|
141
|
-
expect(JSON.stringify(object)).is.equal(b);
|
142
167
|
});
|
143
|
-
});
|
144
|
-
});
|
145
168
|
|
146
|
-
|
147
|
-
describe('.getVia()', function () {
|
169
|
+
})
|
148
170
|
|
171
|
+
describe('.setVia()', function () {
|
149
172
|
|
150
|
-
|
173
|
+
let a;
|
174
|
+
let b;
|
175
|
+
let c;
|
151
176
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
],
|
158
|
-
d: undefined,
|
159
|
-
e: false,
|
160
|
-
f: [
|
161
|
-
{
|
162
|
-
g: false,
|
163
|
-
h: 3,
|
164
|
-
i: ["test2"]
|
165
|
-
}
|
166
|
-
],
|
167
|
-
j: {},
|
168
|
-
k: (new Map).set('m', {n: 3}),
|
169
|
-
l: (new Set).add({n: 4}),
|
170
|
-
o: [
|
171
|
-
{p: {q: 1, r: true}},
|
172
|
-
{p: {q: 2, r: true}},
|
173
|
-
{p: {q: 3, r: true}},
|
174
|
-
{p: {q: 4, r: true}},
|
175
|
-
{p: {q: 5, r: true}}
|
176
|
-
],
|
177
|
-
s: {
|
178
|
-
t: {a: 1},
|
179
|
-
u: {a: 2},
|
180
|
-
v: {a: 3},
|
181
|
-
x: {a: 4}
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
};
|
177
|
+
beforeEach(function () {
|
178
|
+
a = "a.x";
|
179
|
+
b = "true";
|
180
|
+
c = "a.y.d";
|
181
|
+
})
|
186
182
|
|
187
|
-
|
183
|
+
it('.setVia(' + a + ', ' + b + ') should return Pathfinder', function () {
|
184
|
+
expect(pathfinder.setVia(a, b)).is.instanceOf(Pathfinder);
|
185
|
+
});
|
188
186
|
|
187
|
+
it('.setVia(' + a + ', ' + b + ') should change object', function () {
|
188
|
+
pathfinder.setVia(a, b);
|
189
|
+
expect(JSON.stringify(object)).is.equal('{"a":{"b":{"c":[4,"test1",false,null,null],"e":false,"f":[{"g":false,"h":3,"i":["test2"]}],"j":{},"k":{},"l":{}},"x":"true"}}');
|
190
|
+
});
|
189
191
|
|
192
|
+
it('.setVia(' + c + ', ' + b + ') should change object', function () {
|
193
|
+
pathfinder.setVia(c, b);
|
194
|
+
expect(JSON.stringify(object)).is.equal('{"a":{"b":{"c":[4,"test1",false,null,null],"e":false,"f":[{"g":false,"h":3,"i":["test2"]}],"j":{},"k":{},"l":{}},"y":{"d":"true"}}}');
|
190
195
|
});
|
191
196
|
|
197
|
+
});
|
198
|
+
|
199
|
+
|
200
|
+
describe('.exists()', function () {
|
201
|
+
|
202
|
+
|
192
203
|
[
|
193
|
-
['a.b.
|
194
|
-
['a.
|
195
|
-
['a.b.
|
196
|
-
['a.b.
|
197
|
-
['a.b.
|
204
|
+
['a.b.x', false],
|
205
|
+
['a.x', false],
|
206
|
+
['a.b.q', false],
|
207
|
+
['a.b.c.1', true],
|
208
|
+
['a.b.c.0', true],
|
209
|
+
['a.b.d', true],
|
210
|
+
['a.b.f.0.g', true],
|
211
|
+
['a.b.f.0.i.0', true],
|
212
|
+
['a.b.f.0.i.2', false],
|
213
|
+
['a.b.e', true],
|
198
214
|
].forEach(function (data) {
|
199
215
|
|
200
216
|
let a = data.shift()
|
201
217
|
let b = data.shift()
|
202
218
|
|
203
|
-
|
204
|
-
|
205
|
-
expect(
|
219
|
+
|
220
|
+
it('.exists(' + a + ') should return ' + b + ' ', function () {
|
221
|
+
expect(pathfinder.exists(a)).is.equal(b);
|
206
222
|
});
|
207
223
|
|
224
|
+
|
208
225
|
});
|
209
226
|
|
210
|
-
})
|
227
|
+
});
|
228
|
+
|
229
|
+
describe('.deleteVia()', function () {
|
230
|
+
[
|
231
|
+
['a.b.e', '{"a":{"b":{"c":[4,"test1",false,null,null],"f":[{"g":false,"h":3,"i":["test2"]}],"j":{},"k":{},"l":{}}}}'],
|
232
|
+
['a.b.f', '{"a":{"b":{"c":[4,"test1",false,null,null],"e":false,"j":{},"k":{},"l":{}}}}'],
|
233
|
+
['a.b.j', '{"a":{"b":{"c":[4,"test1",false,null,null],"e":false,"f":[{"g":false,"h":3,"i":["test2"]}],"k":{},"l":{}}}}'],
|
211
234
|
|
212
|
-
|
235
|
+
].forEach(function (data) {
|
213
236
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
}
|
221
|
-
b: {
|
222
|
-
x: [
|
223
|
-
{c: 1, d: false}, {c: 2}
|
224
|
-
],
|
225
|
-
y: true
|
226
|
-
},
|
237
|
+
let a = data.shift()
|
238
|
+
let b = data.shift()
|
239
|
+
|
240
|
+
it('.deleteVia(' + a + ') should return ' + b + ' ', function () {
|
241
|
+
pathfinder.deleteVia(a)
|
242
|
+
expect(JSON.stringify(object)).is.equal(b);
|
243
|
+
});
|
227
244
|
});
|
245
|
+
});
|
228
246
|
|
229
|
-
|
247
|
+
describe('.getVia()', function () {
|
248
|
+
describe('.getVia()', function () {
|
249
|
+
|
250
|
+
|
251
|
+
beforeEach(function () {
|
252
|
+
|
253
|
+
object = {
|
254
|
+
a: {
|
255
|
+
b: {
|
256
|
+
c: [
|
257
|
+
4, "test1", false, undefined, parseInt("a")
|
258
|
+
],
|
259
|
+
d: undefined,
|
260
|
+
e: false,
|
261
|
+
f: [
|
262
|
+
{
|
263
|
+
g: false,
|
264
|
+
h: 3,
|
265
|
+
i: ["test2"]
|
266
|
+
}
|
267
|
+
],
|
268
|
+
j: {},
|
269
|
+
k: (new Map).set('m', {n: 3}),
|
270
|
+
l: (new Set).add({n: 4}),
|
271
|
+
o: [
|
272
|
+
{p: {q: 1, r: true}},
|
273
|
+
{p: {q: 2, r: true}},
|
274
|
+
{p: {q: 3, r: true}},
|
275
|
+
{p: {q: 4, r: true}},
|
276
|
+
{p: {q: 5, r: true}}
|
277
|
+
],
|
278
|
+
s: {
|
279
|
+
t: {a: 1},
|
280
|
+
u: {a: 2},
|
281
|
+
v: {a: 3},
|
282
|
+
x: {a: 4}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
}
|
286
|
+
};
|
230
287
|
|
231
|
-
|
232
|
-
var obj = {}
|
233
|
-
map.forEach(function (v, k) {
|
234
|
-
if (v instanceof Map) {
|
235
|
-
obj[k] = mapToObj(v)
|
236
|
-
} else {
|
237
|
-
obj[k] = v
|
238
|
-
}
|
288
|
+
pathfinder = new Pathfinder(object);
|
239
289
|
|
240
|
-
})
|
241
|
-
return obj
|
242
|
-
}
|
243
290
|
|
244
|
-
|
245
|
-
});
|
291
|
+
});
|
246
292
|
|
247
|
-
|
248
|
-
|
249
|
-
|
293
|
+
[
|
294
|
+
['a.b.s.*.a', '[["t",1],["u",2],["v",3],["x",4]]'],
|
295
|
+
['a.b.s.*', '[["t",{"a":1}],["u",{"a":2}],["v",{"a":3}],["x",{"a":4}]]'],
|
296
|
+
['a.b.o.*.p.q', '[["0",1],["1",2],["2",3],["3",4],["4",5]]'],
|
297
|
+
['a.b.o.*.p.r', '[["0",true],["1",true],["2",true],["3",true],["4",true]]'],
|
298
|
+
['a.b.o.*.p', '[["0",{"q":1,"r":true}],["1",{"q":2,"r":true}],["2",{"q":3,"r":true}],["3",{"q":4,"r":true}],["4",{"q":5,"r":true}]]']
|
299
|
+
].forEach(function (data) {
|
250
300
|
|
251
|
-
|
252
|
-
|
253
|
-
['a.b.l.0.n', 4],
|
254
|
-
['a.x', undefined],
|
255
|
-
['a.b.q', undefined],
|
256
|
-
['a.b.c.1', "test1"],
|
257
|
-
['a.b.c.0', 4],
|
258
|
-
['a.b.d', undefined],
|
259
|
-
['a.b.f.0.g', false],
|
260
|
-
['a.b.f.0.i.0', "test2"],
|
261
|
-
['a.b.e', false],
|
262
|
-
].forEach(function (data) {
|
301
|
+
let a = data.shift()
|
302
|
+
let b = data.shift()
|
263
303
|
|
264
|
-
|
265
|
-
|
304
|
+
it('.getVia(' + a + ') should result ' + b, function () {
|
305
|
+
let r = pathfinder.getVia(a)
|
306
|
+
expect(JSON.stringify(Array.from(r))).is.equal(b);
|
307
|
+
});
|
308
|
+
|
309
|
+
});
|
266
310
|
|
311
|
+
})
|
267
312
|
|
268
|
-
it('.getVia(
|
269
|
-
|
313
|
+
it('.getVia() should result ', function () {
|
314
|
+
|
315
|
+
let p = new Pathfinder({
|
316
|
+
a: {
|
317
|
+
x: [
|
318
|
+
{c: 1}, {c: 2}
|
319
|
+
],
|
320
|
+
y: true
|
321
|
+
},
|
322
|
+
b: {
|
323
|
+
x: [
|
324
|
+
{c: 1, d: false}, {c: 2}
|
325
|
+
],
|
326
|
+
y: true
|
327
|
+
},
|
328
|
+
});
|
329
|
+
|
330
|
+
let r = p.getVia("*.x.*.c")
|
331
|
+
|
332
|
+
function mapToObj(map) {
|
333
|
+
var obj = {}
|
334
|
+
map.forEach(function (v, k) {
|
335
|
+
if (v instanceof Map) {
|
336
|
+
obj[k] = mapToObj(v)
|
337
|
+
} else {
|
338
|
+
obj[k] = v
|
339
|
+
}
|
340
|
+
|
341
|
+
})
|
342
|
+
return obj
|
343
|
+
}
|
344
|
+
|
345
|
+
expect(JSON.stringify(mapToObj(r))).is.equal('{"a":{"0":1,"1":2},"b":{"0":1,"1":2}}');
|
270
346
|
});
|
271
347
|
|
348
|
+
it('.getVia(a.b.l.0.n) with map should return 4 ', function () {
|
349
|
+
expect(pathfinder.getVia('a.b.l.0.n')).is.equal(4);
|
350
|
+
});
|
272
351
|
|
273
|
-
|
352
|
+
[
|
353
|
+
['a.b.k.m.n', 3],
|
354
|
+
['a.b.l.0.n', 4],
|
355
|
+
['a.x', undefined],
|
356
|
+
['a.b.q', undefined],
|
357
|
+
['a.b.c.1', "test1"],
|
358
|
+
['a.b.c.0', 4],
|
359
|
+
['a.b.d', undefined],
|
360
|
+
['a.b.f.0.g', false],
|
361
|
+
['a.b.f.0.i.0', "test2"],
|
362
|
+
['a.b.e', false],
|
363
|
+
].forEach(function (data) {
|
274
364
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
365
|
+
let a = data.shift()
|
366
|
+
let b = data.shift()
|
367
|
+
|
368
|
+
|
369
|
+
it('.getVia(' + a + ') should return ' + b + ' ', function () {
|
370
|
+
expect(pathfinder.getVia(a)).is.equal(b);
|
371
|
+
});
|
280
372
|
|
281
|
-
let a = data.shift()
|
282
373
|
|
283
|
-
|
284
|
-
|
374
|
+
});
|
375
|
+
|
376
|
+
[
|
377
|
+
['a.b.d.e'],
|
378
|
+
['a.b.d.x'],
|
379
|
+
['a.b.l.e.n'],
|
380
|
+
].forEach(function (data) {
|
381
|
+
|
382
|
+
let a = data.shift()
|
383
|
+
|
384
|
+
it('.getVia(' + a + ') should throw Error ', function () {
|
385
|
+
expect(() => pathfinder.getVia(a)).to.throw(Error)
|
386
|
+
});
|
387
|
+
|
285
388
|
});
|
286
389
|
|
287
390
|
});
|
288
391
|
|
289
392
|
});
|
290
|
-
|
291
393
|
});
|
292
394
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import {expect} from "chai";
|
2
|
+
import {ConsoleHandler} from "../../../../source/logging/handler/console.js";
|
3
|
+
import {LogEntry} from "../../../../source/logging/logentry.js";
|
4
|
+
import {FATAL} from "../../../../source/logging/logger.js";
|
5
|
+
|
6
|
+
describe('Logging', function () {
|
7
|
+
|
8
|
+
describe('ConsoleHandler', function () {
|
9
|
+
|
10
|
+
it('should create ConsoleHandler', function () {
|
11
|
+
expect(new ConsoleHandler()).to.be.instanceof(ConsoleHandler)
|
12
|
+
});
|
13
|
+
|
14
|
+
it('should log to console', function () {
|
15
|
+
expect(new ConsoleHandler().setAll().log(new LogEntry(FATAL, [1, true, 'message']))).to.be.true;
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
|
20
|
+
});
|
package/test/cases/monster.js
CHANGED
package/test/web/import.js
CHANGED
@@ -3,6 +3,7 @@ import "./prepare.js";
|
|
3
3
|
import "../cases/logging/logger.js";
|
4
4
|
import "../cases/logging/handler.js";
|
5
5
|
import "../cases/logging/logentry.js";
|
6
|
+
import "../cases/logging/handler/console.js";
|
6
7
|
import "../cases/text/formatter.js";
|
7
8
|
import "../cases/dom/updater.js";
|
8
9
|
import "../cases/dom/attributes.js";
|
@@ -10,13 +10,13 @@
|
|
10
10
|
crossorigin="anonymous"
|
11
11
|
referrerpolicy="no-referrer"></script>
|
12
12
|
|
13
|
-
<script src="https://monsterjs.org/dist/1.
|
13
|
+
<script src="https://monsterjs.org/dist/1.17.1/dist/monster.dev.js"></script>
|
14
14
|
|
15
15
|
</head>
|
16
16
|
<body>
|
17
17
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
18
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
19
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
18
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.17.1</h1>
|
19
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Sa 9. Okt 17:21:23 CEST 2021</div>
|
20
20
|
</div>
|
21
21
|
</body>
|
22
22
|
</html>
|
package/test/web/monster.html
CHANGED
@@ -14,8 +14,8 @@
|
|
14
14
|
</head>
|
15
15
|
<body>
|
16
16
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
17
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
18
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
17
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.17.1</h1>
|
18
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Sa 9. Okt 17:21:23 CEST 2021</div>
|
19
19
|
</div>
|
20
20
|
</body>
|
21
21
|
</html>
|