@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.
Files changed (150) hide show
  1. package/CHANGELOG +25 -0
  2. package/README.md +4 -4
  3. package/dist/modules/constants.js +1 -1
  4. package/dist/modules/constraints/abstract.js +1 -1
  5. package/dist/modules/constraints/abstractoperator.js +1 -1
  6. package/dist/modules/constraints/andoperator.js +1 -1
  7. package/dist/modules/constraints/invalid.js +1 -1
  8. package/dist/modules/constraints/isarray.js +1 -1
  9. package/dist/modules/constraints/isobject.js +1 -1
  10. package/dist/modules/constraints/namespace.js +2 -2
  11. package/dist/modules/constraints/oroperator.js +1 -1
  12. package/dist/modules/constraints/valid.js +1 -1
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/diff.js +2 -2
  15. package/dist/modules/data/extend.js +1 -1
  16. package/dist/modules/data/namespace.js +2 -2
  17. package/dist/modules/data/pathfinder.js +2 -2
  18. package/dist/modules/data/pipe.js +1 -1
  19. package/dist/modules/data/transformer.js +1 -1
  20. package/dist/modules/dom/assembler.js +1 -1
  21. package/dist/modules/dom/attributes.js +1 -1
  22. package/dist/modules/dom/constants.js +1 -1
  23. package/dist/modules/dom/customcontrol.js +1 -1
  24. package/dist/modules/dom/customelement.js +1 -1
  25. package/dist/modules/dom/events.js +1 -1
  26. package/dist/modules/dom/locale.js +1 -1
  27. package/dist/modules/dom/namespace.js +2 -2
  28. package/dist/modules/dom/template.js +1 -1
  29. package/dist/modules/dom/theme.js +1 -1
  30. package/dist/modules/dom/updater.js +1 -1
  31. package/dist/modules/dom/util.js +1 -1
  32. package/dist/modules/i18n/locale.js +1 -1
  33. package/dist/modules/i18n/namespace.js +2 -2
  34. package/dist/modules/i18n/provider.js +1 -1
  35. package/dist/modules/i18n/providers/fetch.js +1 -1
  36. package/dist/modules/i18n/providers/namespace.js +2 -2
  37. package/dist/modules/i18n/translations.js +1 -1
  38. package/dist/modules/logging/handler/console.js +2 -2
  39. package/dist/modules/logging/handler/namespace.js +2 -2
  40. package/dist/modules/logging/handler.js +1 -1
  41. package/dist/modules/logging/logentry.js +1 -1
  42. package/dist/modules/logging/logger.js +1 -1
  43. package/dist/modules/logging/namespace.js +2 -2
  44. package/dist/modules/math/namespace.js +2 -2
  45. package/dist/modules/math/random.js +1 -1
  46. package/dist/modules/monster.js +1 -1
  47. package/dist/modules/namespace.js +1 -1
  48. package/dist/modules/text/formatter.js +1 -1
  49. package/dist/modules/text/namespace.js +2 -2
  50. package/dist/modules/types/base.js +1 -1
  51. package/dist/modules/types/basewithoptions.js +1 -1
  52. package/dist/modules/types/global.js +1 -1
  53. package/dist/modules/types/id.js +1 -1
  54. package/dist/modules/types/is.js +1 -1
  55. package/dist/modules/types/namespace.js +2 -2
  56. package/dist/modules/types/observer.js +1 -1
  57. package/dist/modules/types/observerlist.js +1 -1
  58. package/dist/modules/types/proxyobserver.js +1 -1
  59. package/dist/modules/types/queue.js +1 -1
  60. package/dist/modules/types/randomid.js +1 -1
  61. package/dist/modules/types/stack.js +1 -1
  62. package/dist/modules/types/tokenlist.js +1 -1
  63. package/dist/modules/types/typeof.js +1 -1
  64. package/dist/modules/types/uniquequeue.js +1 -1
  65. package/dist/modules/types/validate.js +1 -1
  66. package/dist/modules/types/version.js +2 -2
  67. package/dist/modules/util/clone.js +1 -1
  68. package/dist/modules/util/comparator.js +1 -1
  69. package/dist/modules/util/freeze.js +1 -1
  70. package/dist/modules/util/namespace.js +2 -2
  71. package/dist/monster.dev.js +1293 -943
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +2 -2
  74. package/package.json +1 -1
  75. package/source/constraints/abstract.js +1 -1
  76. package/source/constraints/abstractoperator.js +1 -1
  77. package/source/constraints/andoperator.js +6 -6
  78. package/source/constraints/invalid.js +4 -4
  79. package/source/constraints/isarray.js +4 -4
  80. package/source/constraints/isobject.js +4 -4
  81. package/source/constraints/namespace.js +3 -2
  82. package/source/constraints/oroperator.js +6 -6
  83. package/source/constraints/valid.js +4 -4
  84. package/source/data/buildmap.js +245 -12
  85. package/source/data/diff.js +7 -6
  86. package/source/data/extend.js +3 -3
  87. package/source/data/namespace.js +3 -2
  88. package/source/data/pathfinder.js +15 -11
  89. package/source/data/pipe.js +4 -4
  90. package/source/data/transformer.js +4 -4
  91. package/source/dom/assembler.js +4 -4
  92. package/source/dom/attributes.js +36 -46
  93. package/source/dom/constants.js +16 -14
  94. package/source/dom/customcontrol.js +12 -8
  95. package/source/dom/customelement.js +24 -11
  96. package/source/dom/events.js +6 -6
  97. package/source/dom/locale.js +5 -4
  98. package/source/dom/namespace.js +3 -2
  99. package/source/dom/template.js +6 -6
  100. package/source/dom/theme.js +5 -4
  101. package/source/dom/updater.js +11 -5
  102. package/source/dom/util.js +9 -9
  103. package/source/i18n/locale.js +27 -15
  104. package/source/i18n/namespace.js +3 -2
  105. package/source/i18n/provider.js +3 -3
  106. package/source/i18n/providers/fetch.js +22 -6
  107. package/source/i18n/providers/namespace.js +3 -2
  108. package/source/i18n/translations.js +3 -3
  109. package/source/logging/handler/console.js +34 -10
  110. package/source/logging/handler/namespace.js +3 -2
  111. package/source/logging/handler.js +4 -4
  112. package/source/logging/logentry.js +5 -5
  113. package/source/logging/logger.js +13 -13
  114. package/source/logging/namespace.js +3 -2
  115. package/source/math/namespace.js +3 -2
  116. package/source/math/random.js +3 -3
  117. package/source/namespace.js +1 -1
  118. package/source/text/formatter.js +3 -3
  119. package/source/text/namespace.js +3 -2
  120. package/source/types/base.js +3 -3
  121. package/source/types/basewithoptions.js +3 -3
  122. package/source/types/global.js +7 -7
  123. package/source/types/id.js +3 -3
  124. package/source/types/is.js +30 -30
  125. package/source/types/namespace.js +3 -2
  126. package/source/types/observer.js +4 -4
  127. package/source/types/observerlist.js +3 -3
  128. package/source/types/proxyobserver.js +6 -6
  129. package/source/types/queue.js +4 -4
  130. package/source/types/randomid.js +3 -3
  131. package/source/types/stack.js +3 -3
  132. package/source/types/tokenlist.js +3 -3
  133. package/source/types/typeof.js +4 -4
  134. package/source/types/uniquequeue.js +3 -3
  135. package/source/types/validate.js +34 -34
  136. package/source/types/version.js +7 -7
  137. package/source/util/clone.js +3 -3
  138. package/source/util/comparator.js +37 -7
  139. package/source/util/freeze.js +4 -4
  140. package/source/util/namespace.js +3 -2
  141. package/test/cases/data/buildmap.js +242 -16
  142. package/test/cases/data/diff.js +36 -3
  143. package/test/cases/data/pathfinder.js +298 -196
  144. package/test/cases/logging/handler/console.js +20 -0
  145. package/test/cases/monster.js +1 -1
  146. package/test/web/import.js +1 -0
  147. package/test/web/monster-dev.html +3 -3
  148. package/test/web/monster.html +2 -2
  149. package/test/web/test.html +2 -2
  150. 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 pathfinder, object;
9
-
10
- beforeEach(() => {
11
-
12
- object = {
13
- a: {
14
- b: {
15
- c: [
16
- 4, "test1", false, undefined, parseInt("a")
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
- pathfinder = new Pathfinder(object);
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.b.0.0.c', true, '{"a":{"b":[[{"c":true}]]}}'],
50
- ['a.b.0.c', true, '{"a":{"b":[{"c":true}]}}'],
51
- ['a.b.3.c', true, '{"a":{"b":[null,null,null,{"c":true}]}}'],
52
- ['a.b.c', true, '{"a":{"b":{"c":true}}}']
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 + ', ' + b + ') should result in ' + c, function () {
61
- pf.setVia(a, b)
62
- expect(JSON.stringify(obj)).is.equal(c);
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
- describe('.setVia()', function () {
81
+ });
71
82
 
72
- let a;
73
- let b;
74
- let c;
75
83
 
76
- beforeEach(function () {
77
- a = "a.x";
78
- b = "true";
79
- c = "a.y.d";
80
- })
84
+ describe('api tests', function () {
81
85
 
82
- it('.setVia(' + a + ', ' + b + ') should return Pathfinder', function () {
83
- expect(pathfinder.setVia(a, b)).is.instanceOf(Pathfinder);
84
- });
86
+ let pathfinder, object;
85
87
 
86
- it('.setVia(' + a + ', ' + b + ') should change object', function () {
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
- it('.setVia(' + c + ', ' + b + ') should change object', function () {
92
- pathfinder.setVia(c, b);
93
- 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"}}}');
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
- describe('.exists()', function () {
115
+ });
100
116
 
117
+ describe('create new object', function () {
101
118
 
102
- [
103
- ['a.b.x', false],
104
- ['a.x', false],
105
- ['a.b.q', false],
106
- ['a.b.c.1', true],
107
- ['a.b.c.0', true],
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
- let a = data.shift()
116
- let b = data.shift()
126
+ let a = data.shift()
127
+ let label = typeof a;
128
+ if (a === null) label = 'null';
117
129
 
118
130
 
119
- it('.exists(' + a + ') should return ' + b + ' ', function () {
120
- expect(pathfinder.exists(a)).is.equal(b);
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
- describe('.deleteVia()', function () {
129
- [
130
- ['a.b.e', '{"a":{"b":{"c":[4,"test1",false,null,null],"f":[{"g":false,"h":3,"i":["test2"]}],"j":{},"k":{},"l":{}}}}'],
131
- ['a.b.f', '{"a":{"b":{"c":[4,"test1",false,null,null],"e":false,"j":{},"k":{},"l":{}}}}'],
132
- ['a.b.j', '{"a":{"b":{"c":[4,"test1",false,null,null],"e":false,"f":[{"g":false,"h":3,"i":["test2"]}],"k":{},"l":{}}}}'],
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
- ].forEach(function (data) {
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
- describe('.getVia()', function () {
147
- describe('.getVia()', function () {
169
+ })
148
170
 
171
+ describe('.setVia()', function () {
149
172
 
150
- beforeEach(function () {
173
+ let a;
174
+ let b;
175
+ let c;
151
176
 
152
- object = {
153
- a: {
154
- b: {
155
- c: [
156
- 4, "test1", false, undefined, parseInt("a")
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
- pathfinder = new Pathfinder(object);
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.s.*.a', '[["t",1],["u",2],["v",3],["x",4]]'],
194
- ['a.b.s.*', '[["t",{"a":1}],["u",{"a":2}],["v",{"a":3}],["x",{"a":4}]]'],
195
- ['a.b.o.*.p.q', '[["0",1],["1",2],["2",3],["3",4],["4",5]]'],
196
- ['a.b.o.*.p.r', '[["0",true],["1",true],["2",true],["3",true],["4",true]]'],
197
- ['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}]]']
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
- it('.getVia(' + a + ') should result ' + b, function () {
204
- let r = pathfinder.getVia(a)
205
- expect(JSON.stringify(Array.from(r))).is.equal(b);
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
- it('.getVia() should result ', function () {
235
+ ].forEach(function (data) {
213
236
 
214
- let p = new Pathfinder({
215
- a: {
216
- x: [
217
- {c: 1}, {c: 2}
218
- ],
219
- y: true
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
- let r = p.getVia("*.x.*.c")
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
- function mapToObj(map) {
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
- expect(JSON.stringify(mapToObj(r))).is.equal('{"a":{"0":1,"1":2},"b":{"0":1,"1":2}}');
245
- });
291
+ });
246
292
 
247
- it('.getVia(a.b.l.0.n) with map should return 4 ', function () {
248
- expect(pathfinder.getVia('a.b.l.0.n')).is.equal(4);
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
- ['a.b.k.m.n', 3],
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
- let a = data.shift()
265
- let b = data.shift()
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(' + a + ') should return ' + b + ' ', function () {
269
- expect(pathfinder.getVia(a)).is.equal(b);
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
- ['a.b.d.e'],
277
- ['a.b.d.x'],
278
- ['a.b.l.e.n'],
279
- ].forEach(function (data) {
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
- it('.getVia(' + a + ') should throw Error ', function () {
284
- expect(() => pathfinder.getVia(a)).to.throw(Error)
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
+ });
@@ -9,7 +9,7 @@ describe('Monster', function () {
9
9
  let monsterVersion
10
10
 
11
11
  /**#@+ dont touch, replaced by make with package.json version */
12
- monsterVersion = new Version('1.15.5')
12
+ monsterVersion = new Version('1.17.1')
13
13
  /**#@-*/
14
14
 
15
15
  let m = Monster.getVersion();
@@ -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.15.5/dist/monster.dev.js"></script>
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.15.5</h1>
19
- <div id="lastupdate" style='font-size:0.7em'>last update Fr 24. Sep 10:16:17 CEST 2021</div>
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>
@@ -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.15.5</h1>
18
- <div id="lastupdate" style='font-size:0.7em'>last update Fr 24. Sep 10:16:17 CEST 2021</div>
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>