mol_data_all 1.1.209 → 1.1.210
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/node.d.ts +0 -226
- package/node.deps.json +1 -1
- package/node.esm.js +70 -70
- package/node.esm.js.map +1 -1
- package/node.js +70 -70
- package/node.js.map +1 -1
- package/node.test.js +452 -446
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/test.html +2 -2
- package/web.d.ts +0 -226
- package/web.deps.json +1 -1
- package/web.esm.js +70 -70
- package/web.esm.js.map +1 -1
- package/web.js +70 -70
- package/web.js.map +1 -1
- package/web.test.js +306 -300
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -16,12 +16,18 @@ var $;
|
|
|
16
16
|
$_1.$mol_test_all = [];
|
|
17
17
|
async function $mol_test_run() {
|
|
18
18
|
for (var test of $_1.$mol_test_all) {
|
|
19
|
-
let context = Object.create(
|
|
19
|
+
let context = Object.create($$);
|
|
20
20
|
for (let mock of $_1.$mol_test_mocks)
|
|
21
21
|
await mock(context);
|
|
22
|
-
|
|
22
|
+
const res = test(context);
|
|
23
|
+
if (res instanceof Promise) {
|
|
24
|
+
await new Promise((done, fail) => {
|
|
25
|
+
res.then(done, fail);
|
|
26
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
|
-
|
|
30
|
+
$$.$mol_log3_done({
|
|
25
31
|
place: '$mol_test',
|
|
26
32
|
message: 'All tests passed',
|
|
27
33
|
count: $_1.$mol_test_all.length,
|
|
@@ -39,7 +45,7 @@ var $;
|
|
|
39
45
|
await $mol_test_run();
|
|
40
46
|
}
|
|
41
47
|
finally {
|
|
42
|
-
|
|
48
|
+
$$.$mol_test_complete();
|
|
43
49
|
}
|
|
44
50
|
}, 0);
|
|
45
51
|
}
|
|
@@ -52,10 +58,10 @@ var $;
|
|
|
52
58
|
for (let api of forbidden) {
|
|
53
59
|
context[api] = new Proxy(function () { }, {
|
|
54
60
|
get() {
|
|
55
|
-
$
|
|
61
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
56
62
|
},
|
|
57
63
|
apply() {
|
|
58
|
-
$
|
|
64
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
59
65
|
},
|
|
60
66
|
});
|
|
61
67
|
}
|
|
@@ -83,7 +89,7 @@ var $;
|
|
|
83
89
|
},
|
|
84
90
|
});
|
|
85
91
|
})($ || ($ = {}));
|
|
86
|
-
//test.test.
|
|
92
|
+
//mol/test/test.test.ts
|
|
87
93
|
;
|
|
88
94
|
"use strict";
|
|
89
95
|
var $;
|
|
@@ -92,20 +98,20 @@ var $;
|
|
|
92
98
|
}
|
|
93
99
|
$.$mol_test_complete = $mol_test_complete;
|
|
94
100
|
})($ || ($ = {}));
|
|
95
|
-
//test.web.test.
|
|
101
|
+
//mol/test/test.web.test.ts
|
|
96
102
|
;
|
|
97
103
|
"use strict";
|
|
98
104
|
var $;
|
|
99
105
|
(function ($) {
|
|
100
106
|
})($ || ($ = {}));
|
|
101
|
-
//context.
|
|
107
|
+
//mol/dom/context/context.ts
|
|
102
108
|
;
|
|
103
109
|
"use strict";
|
|
104
110
|
var $;
|
|
105
111
|
(function ($) {
|
|
106
112
|
$.$mol_dom_context = self;
|
|
107
113
|
})($ || ($ = {}));
|
|
108
|
-
//context.web.
|
|
114
|
+
//mol/dom/context/context.web.ts
|
|
109
115
|
;
|
|
110
116
|
"use strict";
|
|
111
117
|
var $;
|
|
@@ -116,7 +122,7 @@ var $;
|
|
|
116
122
|
for (let view of childNodes) {
|
|
117
123
|
if (view == null)
|
|
118
124
|
continue;
|
|
119
|
-
if (view instanceof
|
|
125
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
120
126
|
while (true) {
|
|
121
127
|
if (!nextNode) {
|
|
122
128
|
el.appendChild(view);
|
|
@@ -147,7 +153,7 @@ var $;
|
|
|
147
153
|
nextNode = nextNode.nextSibling;
|
|
148
154
|
}
|
|
149
155
|
else {
|
|
150
|
-
const textNode =
|
|
156
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
151
157
|
el.insertBefore(textNode, nextNode);
|
|
152
158
|
}
|
|
153
159
|
}
|
|
@@ -160,88 +166,88 @@ var $;
|
|
|
160
166
|
}
|
|
161
167
|
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
162
168
|
})($ || ($ = {}));
|
|
163
|
-
//children.
|
|
169
|
+
//mol/dom/render/children/children.ts
|
|
164
170
|
;
|
|
165
171
|
"use strict";
|
|
166
|
-
//error.
|
|
172
|
+
//mol/type/error/error.ts
|
|
167
173
|
;
|
|
168
174
|
"use strict";
|
|
169
|
-
//assert.test.
|
|
175
|
+
//mol/type/assert/assert.test.ts
|
|
170
176
|
;
|
|
171
177
|
"use strict";
|
|
172
|
-
//assert.
|
|
178
|
+
//mol/type/assert/assert.ts
|
|
173
179
|
;
|
|
174
180
|
"use strict";
|
|
175
|
-
//deep.test.
|
|
181
|
+
//mol/type/partial/deep/deep.test.ts
|
|
176
182
|
;
|
|
177
183
|
"use strict";
|
|
178
|
-
//deep.
|
|
184
|
+
//mol/type/partial/deep/deep.ts
|
|
179
185
|
;
|
|
180
186
|
"use strict";
|
|
181
187
|
var $;
|
|
182
188
|
(function ($) {
|
|
183
|
-
|
|
189
|
+
$mol_test({
|
|
184
190
|
'Make empty div'() {
|
|
185
|
-
|
|
191
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
186
192
|
},
|
|
187
193
|
'Define native field'() {
|
|
188
|
-
const dom =
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
195
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
196
|
+
$mol_assert_equal(dom.value, '123');
|
|
191
197
|
},
|
|
192
198
|
'Define classes'() {
|
|
193
|
-
const dom =
|
|
194
|
-
|
|
199
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
200
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
195
201
|
},
|
|
196
202
|
'Define styles'() {
|
|
197
|
-
const dom =
|
|
198
|
-
|
|
203
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
204
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
199
205
|
},
|
|
200
206
|
'Define dataset'() {
|
|
201
|
-
const dom =
|
|
202
|
-
|
|
207
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
208
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
203
209
|
},
|
|
204
210
|
'Define attributes'() {
|
|
205
|
-
const dom =
|
|
206
|
-
|
|
211
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
212
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
207
213
|
},
|
|
208
214
|
'Define child nodes'() {
|
|
209
|
-
const dom =
|
|
215
|
+
const dom = $mol_jsx("div", null,
|
|
210
216
|
"hello",
|
|
211
|
-
|
|
217
|
+
$mol_jsx("strong", null, "world"),
|
|
212
218
|
"!");
|
|
213
|
-
|
|
219
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
214
220
|
},
|
|
215
221
|
'Function as component'() {
|
|
216
222
|
const Button = ({ hint }, target) => {
|
|
217
|
-
return
|
|
223
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
218
224
|
};
|
|
219
|
-
const dom =
|
|
220
|
-
|
|
225
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
226
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
221
227
|
},
|
|
222
228
|
'Nested guid generation'() {
|
|
223
229
|
const Foo = () => {
|
|
224
|
-
return
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
return $mol_jsx("div", null,
|
|
231
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
232
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
227
233
|
};
|
|
228
234
|
const Bar = (props, icon) => {
|
|
229
|
-
return
|
|
235
|
+
return $mol_jsx("span", null, icon);
|
|
230
236
|
};
|
|
231
|
-
const dom =
|
|
232
|
-
|
|
237
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
238
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
233
239
|
},
|
|
234
240
|
'Fail on non unique ids'() {
|
|
235
241
|
const App = () => {
|
|
236
|
-
return
|
|
237
|
-
|
|
238
|
-
|
|
242
|
+
return $mol_jsx("div", null,
|
|
243
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
244
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
239
245
|
};
|
|
240
|
-
|
|
246
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
241
247
|
},
|
|
242
248
|
});
|
|
243
249
|
})($ || ($ = {}));
|
|
244
|
-
//jsx.test.
|
|
250
|
+
//mol/jsx/jsx.test.tsx
|
|
245
251
|
;
|
|
246
252
|
"use strict";
|
|
247
253
|
var $;
|
|
@@ -250,15 +256,15 @@ var $;
|
|
|
250
256
|
$.$mol_jsx_booked = null;
|
|
251
257
|
$.$mol_jsx_document = {
|
|
252
258
|
getElementById: () => null,
|
|
253
|
-
createElementNS: (space, name) =>
|
|
254
|
-
createDocumentFragment: () =>
|
|
259
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
260
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
255
261
|
};
|
|
256
262
|
$.$mol_jsx_frag = '';
|
|
257
263
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
258
264
|
const id = props && props.id || '';
|
|
259
265
|
if (Elem && $.$mol_jsx_booked) {
|
|
260
266
|
if ($.$mol_jsx_booked.has(id)) {
|
|
261
|
-
|
|
267
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
262
268
|
}
|
|
263
269
|
else {
|
|
264
270
|
$.$mol_jsx_booked.add(id);
|
|
@@ -297,7 +303,7 @@ var $;
|
|
|
297
303
|
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
298
304
|
: $.$mol_jsx_document.createDocumentFragment();
|
|
299
305
|
}
|
|
300
|
-
|
|
306
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
301
307
|
if (!Elem)
|
|
302
308
|
return node;
|
|
303
309
|
for (const key in props) {
|
|
@@ -323,77 +329,77 @@ var $;
|
|
|
323
329
|
}
|
|
324
330
|
$.$mol_jsx = $mol_jsx;
|
|
325
331
|
})($ || ($ = {}));
|
|
326
|
-
//jsx.
|
|
332
|
+
//mol/jsx/jsx.ts
|
|
327
333
|
;
|
|
328
334
|
"use strict";
|
|
329
335
|
var $;
|
|
330
336
|
(function ($) {
|
|
331
|
-
|
|
337
|
+
$mol_test({
|
|
332
338
|
'nulls & undefineds'() {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
339
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
340
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
341
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
342
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
337
343
|
},
|
|
338
344
|
'number'() {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
345
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
346
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
347
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
348
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
349
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
344
350
|
},
|
|
345
351
|
'POJO'() {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
353
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
354
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
355
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
356
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
357
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
352
358
|
},
|
|
353
359
|
'Array'() {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
360
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
361
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
362
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
363
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
358
364
|
},
|
|
359
365
|
'Non POJO are different'() {
|
|
360
366
|
class Thing extends Object {
|
|
361
367
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
368
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
369
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
370
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
365
371
|
},
|
|
366
372
|
'same POJOs with cyclic reference'() {
|
|
367
373
|
const a = { foo: {} };
|
|
368
374
|
a['self'] = a;
|
|
369
375
|
const b = { foo: {} };
|
|
370
376
|
b['self'] = b;
|
|
371
|
-
|
|
377
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
372
378
|
},
|
|
373
379
|
'Date'() {
|
|
374
|
-
|
|
375
|
-
|
|
380
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
381
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
376
382
|
},
|
|
377
383
|
'RegExp'() {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
384
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
385
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
386
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
381
387
|
},
|
|
382
388
|
'Map'() {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
389
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
390
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
391
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
392
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
387
393
|
},
|
|
388
394
|
'Set'() {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
395
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
396
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
397
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
392
398
|
},
|
|
393
399
|
'Uint8Array'() {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
400
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
401
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
402
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
397
403
|
},
|
|
398
404
|
'Custom comparator'() {
|
|
399
405
|
class User {
|
|
@@ -407,17 +413,17 @@ var $;
|
|
|
407
413
|
return this.name;
|
|
408
414
|
}
|
|
409
415
|
}
|
|
410
|
-
|
|
411
|
-
|
|
416
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
417
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
412
418
|
},
|
|
413
419
|
});
|
|
414
420
|
})($ || ($ = {}));
|
|
415
|
-
//deep.test.
|
|
421
|
+
//mol/compare/deep/deep.test.tsx
|
|
416
422
|
;
|
|
417
423
|
"use strict";
|
|
418
424
|
var $;
|
|
419
425
|
(function ($) {
|
|
420
|
-
|
|
426
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
421
427
|
function $mol_compare_deep(left, right) {
|
|
422
428
|
if (Object.is(left, right))
|
|
423
429
|
return true;
|
|
@@ -443,7 +449,7 @@ var $;
|
|
|
443
449
|
return Object.is(left.valueOf(), right['valueOf']());
|
|
444
450
|
if (left instanceof RegExp)
|
|
445
451
|
return left.source === right['source'] && left.flags === right['flags'];
|
|
446
|
-
let left_cache =
|
|
452
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
447
453
|
if (left_cache) {
|
|
448
454
|
const right_cache = left_cache.get(right);
|
|
449
455
|
if (typeof right_cache === 'boolean')
|
|
@@ -451,7 +457,7 @@ var $;
|
|
|
451
457
|
}
|
|
452
458
|
else {
|
|
453
459
|
left_cache = new WeakMap([[right, true]]);
|
|
454
|
-
|
|
460
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
455
461
|
}
|
|
456
462
|
let result;
|
|
457
463
|
try {
|
|
@@ -535,50 +541,50 @@ var $;
|
|
|
535
541
|
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
536
542
|
}
|
|
537
543
|
})($ || ($ = {}));
|
|
538
|
-
//deep.
|
|
544
|
+
//mol/compare/deep/deep.ts
|
|
539
545
|
;
|
|
540
546
|
"use strict";
|
|
541
547
|
var $;
|
|
542
548
|
(function ($) {
|
|
543
549
|
function $mol_dom_serialize(node) {
|
|
544
|
-
const serializer = new
|
|
550
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
545
551
|
return serializer.serializeToString(node);
|
|
546
552
|
}
|
|
547
553
|
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
548
554
|
})($ || ($ = {}));
|
|
549
|
-
//serialize.
|
|
555
|
+
//mol/dom/serialize/serialize.ts
|
|
550
556
|
;
|
|
551
557
|
"use strict";
|
|
552
558
|
var $;
|
|
553
559
|
(function ($) {
|
|
554
|
-
|
|
560
|
+
$mol_test({
|
|
555
561
|
'must be false'() {
|
|
556
|
-
|
|
562
|
+
$mol_assert_not(0);
|
|
557
563
|
},
|
|
558
564
|
'must be true'() {
|
|
559
|
-
|
|
565
|
+
$mol_assert_ok(1);
|
|
560
566
|
},
|
|
561
567
|
'two must be equal'() {
|
|
562
|
-
|
|
568
|
+
$mol_assert_equal(2, 2);
|
|
563
569
|
},
|
|
564
570
|
'three must be equal'() {
|
|
565
|
-
|
|
571
|
+
$mol_assert_equal(2, 2, 2);
|
|
566
572
|
},
|
|
567
573
|
'two must be unique'() {
|
|
568
|
-
|
|
574
|
+
$mol_assert_unique([3], [3]);
|
|
569
575
|
},
|
|
570
576
|
'three must be unique'() {
|
|
571
|
-
|
|
577
|
+
$mol_assert_unique([3], [3], [3]);
|
|
572
578
|
},
|
|
573
579
|
'two must be alike'() {
|
|
574
|
-
|
|
580
|
+
$mol_assert_like([3], [3]);
|
|
575
581
|
},
|
|
576
582
|
'three must be alike'() {
|
|
577
|
-
|
|
583
|
+
$mol_assert_like([3], [3], [3]);
|
|
578
584
|
},
|
|
579
585
|
});
|
|
580
586
|
})($ || ($ = {}));
|
|
581
|
-
//assert.test.
|
|
587
|
+
//mol/assert/assert.test.ts
|
|
582
588
|
;
|
|
583
589
|
"use strict";
|
|
584
590
|
var $;
|
|
@@ -586,13 +592,13 @@ var $;
|
|
|
586
592
|
function $mol_assert_ok(value) {
|
|
587
593
|
if (value)
|
|
588
594
|
return;
|
|
589
|
-
|
|
595
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
590
596
|
}
|
|
591
597
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
592
598
|
function $mol_assert_not(value) {
|
|
593
599
|
if (!value)
|
|
594
600
|
return;
|
|
595
|
-
|
|
601
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
596
602
|
}
|
|
597
603
|
$.$mol_assert_not = $mol_assert_not;
|
|
598
604
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
@@ -616,7 +622,7 @@ var $;
|
|
|
616
622
|
finally {
|
|
617
623
|
$.$mol_fail = fail;
|
|
618
624
|
}
|
|
619
|
-
|
|
625
|
+
$mol_fail(new Error('Not failed'));
|
|
620
626
|
}
|
|
621
627
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
622
628
|
function $mol_assert_equal(...args) {
|
|
@@ -627,7 +633,7 @@ var $;
|
|
|
627
633
|
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
628
634
|
continue;
|
|
629
635
|
if (args[i] !== args[j])
|
|
630
|
-
|
|
636
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
631
637
|
}
|
|
632
638
|
}
|
|
633
639
|
}
|
|
@@ -638,7 +644,7 @@ var $;
|
|
|
638
644
|
if (i === j)
|
|
639
645
|
continue;
|
|
640
646
|
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
641
|
-
|
|
647
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
642
648
|
}
|
|
643
649
|
}
|
|
644
650
|
}
|
|
@@ -646,7 +652,7 @@ var $;
|
|
|
646
652
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
647
653
|
function $mol_assert_like(head, ...tail) {
|
|
648
654
|
for (let [index, value] of Object.entries(tail)) {
|
|
649
|
-
if (
|
|
655
|
+
if (!$mol_compare_deep(value, head)) {
|
|
650
656
|
const print = (val) => {
|
|
651
657
|
if (!val)
|
|
652
658
|
return val;
|
|
@@ -662,217 +668,217 @@ var $;
|
|
|
662
668
|
return val;
|
|
663
669
|
}
|
|
664
670
|
};
|
|
665
|
-
return
|
|
671
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
666
672
|
}
|
|
667
673
|
}
|
|
668
674
|
}
|
|
669
675
|
$.$mol_assert_like = $mol_assert_like;
|
|
670
676
|
function $mol_assert_dom(left, right) {
|
|
671
|
-
$mol_assert_equal(
|
|
677
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
672
678
|
}
|
|
673
679
|
$.$mol_assert_dom = $mol_assert_dom;
|
|
674
680
|
})($ || ($ = {}));
|
|
675
|
-
//assert.
|
|
681
|
+
//mol/assert/assert.ts
|
|
676
682
|
;
|
|
677
683
|
"use strict";
|
|
678
684
|
var $;
|
|
679
685
|
(function ($) {
|
|
680
|
-
|
|
686
|
+
$mol_test({
|
|
681
687
|
'equal paths'() {
|
|
682
|
-
const diff =
|
|
683
|
-
|
|
688
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
689
|
+
$mol_assert_like(diff, {
|
|
684
690
|
prefix: [1, 2, 3, 4],
|
|
685
691
|
suffix: [[], [], []],
|
|
686
692
|
});
|
|
687
693
|
},
|
|
688
694
|
'different suffix'() {
|
|
689
|
-
const diff =
|
|
690
|
-
|
|
695
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
696
|
+
$mol_assert_like(diff, {
|
|
691
697
|
prefix: [1, 2],
|
|
692
698
|
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
693
699
|
});
|
|
694
700
|
},
|
|
695
701
|
'one contains other'() {
|
|
696
|
-
const diff =
|
|
697
|
-
|
|
702
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
703
|
+
$mol_assert_like(diff, {
|
|
698
704
|
prefix: [1, 2],
|
|
699
705
|
suffix: [[3, 4], [], [3]],
|
|
700
706
|
});
|
|
701
707
|
},
|
|
702
708
|
'fully different'() {
|
|
703
|
-
const diff =
|
|
704
|
-
|
|
709
|
+
const diff = $mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
710
|
+
$mol_assert_like(diff, {
|
|
705
711
|
prefix: [],
|
|
706
712
|
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
707
713
|
});
|
|
708
714
|
},
|
|
709
715
|
});
|
|
710
716
|
})($ || ($ = {}));
|
|
711
|
-
//path.test.
|
|
717
|
+
//mol/diff/path/path.test.ts
|
|
712
718
|
;
|
|
713
719
|
"use strict";
|
|
714
720
|
var $;
|
|
715
721
|
(function ($) {
|
|
716
|
-
|
|
722
|
+
$mol_test({
|
|
717
723
|
'Is number'() {
|
|
718
|
-
|
|
724
|
+
$mol_data_number(0);
|
|
719
725
|
},
|
|
720
726
|
'Is not number'() {
|
|
721
|
-
|
|
722
|
-
|
|
727
|
+
$mol_assert_fail(() => {
|
|
728
|
+
$mol_data_number('x');
|
|
723
729
|
}, 'x is not a number');
|
|
724
730
|
},
|
|
725
731
|
'Is object number'() {
|
|
726
|
-
|
|
727
|
-
|
|
732
|
+
$mol_assert_fail(() => {
|
|
733
|
+
$mol_data_number(new Number(''));
|
|
728
734
|
}, '0 is not a number');
|
|
729
735
|
},
|
|
730
736
|
});
|
|
731
737
|
})($ || ($ = {}));
|
|
732
|
-
//number.test.
|
|
738
|
+
//mol/data/number/number.test.ts
|
|
733
739
|
;
|
|
734
740
|
"use strict";
|
|
735
741
|
var $;
|
|
736
742
|
(function ($) {
|
|
737
|
-
|
|
743
|
+
$mol_test({
|
|
738
744
|
'config by value'() {
|
|
739
|
-
const N =
|
|
740
|
-
|
|
745
|
+
const N = $mol_data_setup((a) => a, 5);
|
|
746
|
+
$mol_assert_equal(N.config, 5);
|
|
741
747
|
},
|
|
742
748
|
});
|
|
743
749
|
})($ || ($ = {}));
|
|
744
|
-
//setup.test.
|
|
750
|
+
//mol/data/setup/setup.test.ts
|
|
745
751
|
;
|
|
746
752
|
"use strict";
|
|
747
753
|
var $;
|
|
748
754
|
(function ($) {
|
|
749
|
-
|
|
755
|
+
$mol_test({
|
|
750
756
|
'Is empty array'() {
|
|
751
|
-
|
|
757
|
+
$mol_data_array($mol_data_number)([]);
|
|
752
758
|
},
|
|
753
759
|
'Is array'() {
|
|
754
|
-
|
|
760
|
+
$mol_data_array($mol_data_number)([1, 2]);
|
|
755
761
|
},
|
|
756
762
|
'Is not array'() {
|
|
757
|
-
|
|
758
|
-
|
|
763
|
+
$mol_assert_fail(() => {
|
|
764
|
+
$mol_data_array($mol_data_number)({ [0]: 1, length: 1, map: () => { } });
|
|
759
765
|
}, '[object Object] is not an array');
|
|
760
766
|
},
|
|
761
767
|
'Has wrong item'() {
|
|
762
|
-
|
|
763
|
-
|
|
768
|
+
$mol_assert_fail(() => {
|
|
769
|
+
$mol_data_array($mol_data_number)([1, '1']);
|
|
764
770
|
}, '[1] 1 is not a number');
|
|
765
771
|
},
|
|
766
772
|
'Has wrong deep item'() {
|
|
767
|
-
|
|
768
|
-
|
|
773
|
+
$mol_assert_fail(() => {
|
|
774
|
+
$mol_data_array($mol_data_array($mol_data_number))([[], [0, 0, false]]);
|
|
769
775
|
}, '[1] [2] false is not a number');
|
|
770
776
|
},
|
|
771
777
|
});
|
|
772
778
|
})($ || ($ = {}));
|
|
773
|
-
//array.test.
|
|
779
|
+
//mol/data/array/array.test.ts
|
|
774
780
|
;
|
|
775
781
|
"use strict";
|
|
776
782
|
var $;
|
|
777
783
|
(function ($) {
|
|
778
|
-
|
|
784
|
+
$mol_test({
|
|
779
785
|
'Is boolean - true'() {
|
|
780
|
-
|
|
786
|
+
$mol_data_boolean(true);
|
|
781
787
|
},
|
|
782
788
|
'Is boolean - false'() {
|
|
783
|
-
|
|
789
|
+
$mol_data_boolean(false);
|
|
784
790
|
},
|
|
785
791
|
'Is not boolean'() {
|
|
786
|
-
|
|
787
|
-
|
|
792
|
+
$mol_assert_fail(() => {
|
|
793
|
+
$mol_data_boolean('x');
|
|
788
794
|
}, 'x is not a boolean');
|
|
789
795
|
},
|
|
790
796
|
'Is object boolean'() {
|
|
791
|
-
|
|
792
|
-
|
|
797
|
+
$mol_assert_fail(() => {
|
|
798
|
+
$mol_data_boolean(new Boolean(''));
|
|
793
799
|
}, 'false is not a boolean');
|
|
794
800
|
},
|
|
795
801
|
});
|
|
796
802
|
})($ || ($ = {}));
|
|
797
|
-
//boolean.test.
|
|
803
|
+
//mol/data/boolean/boolean.test.ts
|
|
798
804
|
;
|
|
799
805
|
"use strict";
|
|
800
806
|
var $;
|
|
801
807
|
(function ($) {
|
|
802
|
-
|
|
808
|
+
$mol_test({
|
|
803
809
|
'is same number'() {
|
|
804
|
-
|
|
810
|
+
$mol_data_const(Number.NaN)(Number.NaN);
|
|
805
811
|
},
|
|
806
812
|
'is different number'() {
|
|
807
|
-
const Five =
|
|
808
|
-
|
|
813
|
+
const Five = $mol_data_const(5);
|
|
814
|
+
$mol_assert_fail(() => Five(6), '6 is not 5');
|
|
809
815
|
},
|
|
810
816
|
});
|
|
811
817
|
})($ || ($ = {}));
|
|
812
|
-
//const.test.
|
|
818
|
+
//mol/data/const/const.test.ts
|
|
813
819
|
;
|
|
814
820
|
"use strict";
|
|
815
821
|
var $;
|
|
816
822
|
(function ($) {
|
|
817
|
-
|
|
823
|
+
$mol_test({
|
|
818
824
|
'Is string'() {
|
|
819
|
-
|
|
825
|
+
$mol_data_string('');
|
|
820
826
|
},
|
|
821
827
|
'Is not string'() {
|
|
822
|
-
|
|
823
|
-
|
|
828
|
+
$mol_assert_fail(() => {
|
|
829
|
+
$mol_data_string(0);
|
|
824
830
|
}, '0 is not a string');
|
|
825
831
|
},
|
|
826
832
|
'Is object string'() {
|
|
827
|
-
|
|
828
|
-
|
|
833
|
+
$mol_assert_fail(() => {
|
|
834
|
+
$mol_data_string(new String('x'));
|
|
829
835
|
}, 'x is not a string');
|
|
830
836
|
},
|
|
831
837
|
});
|
|
832
838
|
})($ || ($ = {}));
|
|
833
|
-
//string.test.
|
|
839
|
+
//mol/data/string/string.test.ts
|
|
834
840
|
;
|
|
835
841
|
"use strict";
|
|
836
842
|
var $;
|
|
837
843
|
(function ($) {
|
|
838
|
-
|
|
844
|
+
$mol_test({
|
|
839
845
|
'Is fit'() {
|
|
840
|
-
|
|
846
|
+
$mol_data_pattern(/^-$/)('-');
|
|
841
847
|
},
|
|
842
848
|
'Is not fit'() {
|
|
843
|
-
|
|
844
|
-
|
|
849
|
+
$mol_assert_fail(() => {
|
|
850
|
+
$mol_data_pattern(/^-$/)('+');
|
|
845
851
|
}, '+ is not a /^-$/');
|
|
846
852
|
},
|
|
847
853
|
});
|
|
848
854
|
})($ || ($ = {}));
|
|
849
|
-
//pattern.test.
|
|
855
|
+
//mol/data/pattern/pattern.test.ts
|
|
850
856
|
;
|
|
851
857
|
"use strict";
|
|
852
858
|
var $;
|
|
853
859
|
(function ($) {
|
|
854
|
-
|
|
860
|
+
$mol_test({
|
|
855
861
|
'Is email'() {
|
|
856
|
-
|
|
862
|
+
$mol_data_email('foo@bar');
|
|
857
863
|
},
|
|
858
864
|
'Has not host'() {
|
|
859
|
-
|
|
860
|
-
|
|
865
|
+
$mol_assert_fail(() => {
|
|
866
|
+
$mol_data_email('foo@');
|
|
861
867
|
}, 'foo@ is not a /.+@.+/');
|
|
862
868
|
},
|
|
863
869
|
'Has not name'() {
|
|
864
|
-
|
|
865
|
-
|
|
870
|
+
$mol_assert_fail(() => {
|
|
871
|
+
$mol_data_email('@bar');
|
|
866
872
|
}, '@bar is not a /.+@.+/');
|
|
867
873
|
},
|
|
868
874
|
'Has not @'() {
|
|
869
|
-
|
|
870
|
-
|
|
875
|
+
$mol_assert_fail(() => {
|
|
876
|
+
$mol_data_email('foo.bar');
|
|
871
877
|
}, 'foo.bar is not a /.+@.+/');
|
|
872
878
|
},
|
|
873
879
|
});
|
|
874
880
|
})($ || ($ = {}));
|
|
875
|
-
//email.test.
|
|
881
|
+
//mol/data/email/email.test.ts
|
|
876
882
|
;
|
|
877
883
|
"use strict";
|
|
878
884
|
var $;
|
|
@@ -882,28 +888,28 @@ var $;
|
|
|
882
888
|
sex[sex["male"] = 0] = "male";
|
|
883
889
|
sex[sex["female"] = 1] = "female";
|
|
884
890
|
})(sex || (sex = {}));
|
|
885
|
-
const Sex =
|
|
886
|
-
|
|
891
|
+
const Sex = $mol_data_enum('sex', sex);
|
|
892
|
+
$mol_test({
|
|
887
893
|
'config of enum'() {
|
|
888
|
-
|
|
894
|
+
$mol_assert_like(Sex.config, {
|
|
889
895
|
name: 'sex',
|
|
890
896
|
dict: sex,
|
|
891
897
|
});
|
|
892
898
|
},
|
|
893
899
|
'name of enum'() {
|
|
894
|
-
|
|
900
|
+
$mol_assert_equal(Sex.config.name, 'sex');
|
|
895
901
|
},
|
|
896
902
|
'Is right value of enum'() {
|
|
897
|
-
|
|
903
|
+
$mol_assert_equal(Sex(0), sex.male);
|
|
898
904
|
},
|
|
899
905
|
'Is wrong value of enum'() {
|
|
900
|
-
|
|
906
|
+
$mol_assert_fail(() => Sex(2), `2 is not value of sex enum`);
|
|
901
907
|
},
|
|
902
908
|
'Is name instead of value'() {
|
|
903
|
-
|
|
909
|
+
$mol_assert_fail(() => Sex('male'), `male is not value of sex enum`);
|
|
904
910
|
},
|
|
905
911
|
'Is common object field'() {
|
|
906
|
-
|
|
912
|
+
$mol_assert_fail(() => Sex('__proto__'), `__proto__ is not value of sex enum`);
|
|
907
913
|
},
|
|
908
914
|
});
|
|
909
915
|
let gender;
|
|
@@ -911,187 +917,187 @@ var $;
|
|
|
911
917
|
gender["bisexual"] = "bisexual";
|
|
912
918
|
gender["trans"] = "transgender";
|
|
913
919
|
})(gender || (gender = {}));
|
|
914
|
-
const Gender =
|
|
915
|
-
|
|
920
|
+
const Gender = $mol_data_enum('gender', gender);
|
|
921
|
+
$mol_test({
|
|
916
922
|
'config of enum'() {
|
|
917
|
-
|
|
923
|
+
$mol_assert_like(Gender.config, {
|
|
918
924
|
name: 'gender',
|
|
919
925
|
dict: gender,
|
|
920
926
|
});
|
|
921
927
|
},
|
|
922
928
|
'Is right value of enum'() {
|
|
923
|
-
|
|
929
|
+
$mol_assert_equal(Gender('transgender'), gender.trans);
|
|
924
930
|
},
|
|
925
931
|
'Is wrong value of enum'() {
|
|
926
|
-
|
|
932
|
+
$mol_assert_fail(() => Gender('xxx'), `xxx is not value of gender enum`);
|
|
927
933
|
},
|
|
928
934
|
'Is name instead of value'() {
|
|
929
|
-
|
|
935
|
+
$mol_assert_fail(() => Gender('trans'), `trans is not value of gender enum`);
|
|
930
936
|
},
|
|
931
937
|
'Is common object field'() {
|
|
932
|
-
|
|
938
|
+
$mol_assert_fail(() => Gender('__proto__'), `__proto__ is not value of gender enum`);
|
|
933
939
|
},
|
|
934
940
|
});
|
|
935
941
|
})($ || ($ = {}));
|
|
936
|
-
//enum.test.
|
|
942
|
+
//mol/data/enum/enum.test.ts
|
|
937
943
|
;
|
|
938
944
|
"use strict";
|
|
939
945
|
var $;
|
|
940
946
|
(function ($) {
|
|
941
|
-
|
|
947
|
+
$mol_test({
|
|
942
948
|
'Is same class'() {
|
|
943
|
-
|
|
949
|
+
$mol_data_instance(Date)(new Date);
|
|
944
950
|
},
|
|
945
951
|
'Is sub class'() {
|
|
946
|
-
|
|
952
|
+
$mol_data_instance(Object)(new Date);
|
|
947
953
|
},
|
|
948
954
|
'Is super class'() {
|
|
949
|
-
|
|
950
|
-
|
|
955
|
+
$mol_assert_fail(() => {
|
|
956
|
+
$mol_data_instance(Date)(new Object);
|
|
951
957
|
}, '[object Object] is not a Date');
|
|
952
958
|
},
|
|
953
959
|
'Is another class'() {
|
|
954
|
-
|
|
955
|
-
|
|
960
|
+
$mol_assert_fail(() => {
|
|
961
|
+
$mol_data_instance(Date)(new Array);
|
|
956
962
|
}, ' is not a Date');
|
|
957
963
|
},
|
|
958
964
|
'Is not object'() {
|
|
959
|
-
|
|
960
|
-
|
|
965
|
+
$mol_assert_fail(() => {
|
|
966
|
+
$mol_data_instance(Date)(null);
|
|
961
967
|
}, 'null is not a Date');
|
|
962
968
|
},
|
|
963
969
|
});
|
|
964
970
|
})($ || ($ = {}));
|
|
965
|
-
//instance.test.
|
|
971
|
+
//mol/data/instance/instance.test.ts
|
|
966
972
|
;
|
|
967
973
|
"use strict";
|
|
968
974
|
var $;
|
|
969
975
|
(function ($) {
|
|
970
|
-
|
|
976
|
+
$mol_test({
|
|
971
977
|
'Is integer'() {
|
|
972
|
-
|
|
978
|
+
$mol_data_integer(0);
|
|
973
979
|
},
|
|
974
980
|
'Is float'() {
|
|
975
|
-
|
|
976
|
-
|
|
981
|
+
$mol_assert_fail(() => {
|
|
982
|
+
$mol_data_integer(1.1);
|
|
977
983
|
}, '1.1 is not an integer');
|
|
978
984
|
},
|
|
979
985
|
});
|
|
980
986
|
})($ || ($ = {}));
|
|
981
|
-
//integer.test.
|
|
987
|
+
//mol/data/integer/integer.test.ts
|
|
982
988
|
;
|
|
983
989
|
"use strict";
|
|
984
990
|
var $;
|
|
985
991
|
(function ($) {
|
|
986
|
-
|
|
992
|
+
$mol_test({
|
|
987
993
|
'Nominal typing'() {
|
|
988
|
-
const Weight =
|
|
989
|
-
const Length =
|
|
994
|
+
const Weight = $mol_data_nominal({ Weight: $mol_data_integer });
|
|
995
|
+
const Length = $mol_data_nominal({ Length: $mol_data_integer });
|
|
990
996
|
let len = Length(10);
|
|
991
997
|
len = Length(20);
|
|
992
998
|
len = 20;
|
|
993
999
|
},
|
|
994
1000
|
});
|
|
995
1001
|
})($ || ($ = {}));
|
|
996
|
-
//nominal.test.
|
|
1002
|
+
//mol/data/nominal/nominal.test.ts
|
|
997
1003
|
;
|
|
998
1004
|
"use strict";
|
|
999
1005
|
var $;
|
|
1000
1006
|
(function ($) {
|
|
1001
|
-
|
|
1007
|
+
$mol_test({
|
|
1002
1008
|
'Is null'() {
|
|
1003
|
-
|
|
1009
|
+
$mol_data_nullable($mol_data_number)(null);
|
|
1004
1010
|
},
|
|
1005
1011
|
'Is not null'() {
|
|
1006
|
-
|
|
1012
|
+
$mol_data_nullable($mol_data_number)(0);
|
|
1007
1013
|
},
|
|
1008
1014
|
'Is undefined'() {
|
|
1009
|
-
|
|
1010
|
-
const Type =
|
|
1015
|
+
$mol_assert_fail(() => {
|
|
1016
|
+
const Type = $mol_data_nullable($mol_data_number);
|
|
1011
1017
|
Type(undefined);
|
|
1012
1018
|
}, 'undefined is not a number');
|
|
1013
1019
|
},
|
|
1014
1020
|
});
|
|
1015
1021
|
})($ || ($ = {}));
|
|
1016
|
-
//nullable.test.
|
|
1022
|
+
//mol/data/nullable/nullable.test.ts
|
|
1017
1023
|
;
|
|
1018
1024
|
"use strict";
|
|
1019
1025
|
var $;
|
|
1020
1026
|
(function ($) {
|
|
1021
|
-
const Age =
|
|
1022
|
-
const Age_or_zero =
|
|
1023
|
-
|
|
1027
|
+
const Age = $mol_data_optional($mol_data_number);
|
|
1028
|
+
const Age_or_zero = $mol_data_optional($mol_data_number, () => 0);
|
|
1029
|
+
$mol_test({
|
|
1024
1030
|
'Is not present'() {
|
|
1025
|
-
|
|
1031
|
+
$mol_assert_equal(Age(undefined), undefined);
|
|
1026
1032
|
},
|
|
1027
1033
|
'Is present'() {
|
|
1028
|
-
|
|
1034
|
+
$mol_assert_equal(Age(0), 0);
|
|
1029
1035
|
},
|
|
1030
1036
|
'Fallbacked'() {
|
|
1031
|
-
|
|
1037
|
+
$mol_assert_equal(Age_or_zero(undefined), 0);
|
|
1032
1038
|
},
|
|
1033
1039
|
'Is null'() {
|
|
1034
|
-
|
|
1040
|
+
$mol_assert_fail(() => Age(null), 'null is not a number');
|
|
1035
1041
|
},
|
|
1036
1042
|
});
|
|
1037
1043
|
})($ || ($ = {}));
|
|
1038
|
-
//optional.test.
|
|
1044
|
+
//mol/data/optional/optional.test.ts
|
|
1039
1045
|
;
|
|
1040
1046
|
"use strict";
|
|
1041
|
-
//equals.test.
|
|
1047
|
+
//mol/type/equals/equals.test.ts
|
|
1042
1048
|
;
|
|
1043
1049
|
"use strict";
|
|
1044
|
-
//merge.test.
|
|
1050
|
+
//mol/type/merge/merge.test.ts
|
|
1045
1051
|
;
|
|
1046
1052
|
"use strict";
|
|
1047
|
-
//undefined.test.
|
|
1053
|
+
//mol/type/partial/undefined/undefined.test.ts
|
|
1048
1054
|
;
|
|
1049
1055
|
"use strict";
|
|
1050
1056
|
var $;
|
|
1051
1057
|
(function ($) {
|
|
1052
|
-
|
|
1058
|
+
$mol_test({
|
|
1053
1059
|
'Fit to record'() {
|
|
1054
|
-
const User =
|
|
1060
|
+
const User = $mol_data_record({ age: $mol_data_number });
|
|
1055
1061
|
User({ age: 0 });
|
|
1056
1062
|
},
|
|
1057
1063
|
'Extends record'() {
|
|
1058
|
-
const User =
|
|
1064
|
+
const User = $mol_data_record({ age: $mol_data_number });
|
|
1059
1065
|
User({ age: 0, name: 'Jin' });
|
|
1060
1066
|
},
|
|
1061
1067
|
'Shrinks record'() {
|
|
1062
|
-
|
|
1063
|
-
const User =
|
|
1068
|
+
$mol_assert_fail(() => {
|
|
1069
|
+
const User = $mol_data_record({ age: $mol_data_number, name: $mol_data_string });
|
|
1064
1070
|
User({ age: 0 });
|
|
1065
1071
|
}, '["name"] undefined is not a string');
|
|
1066
1072
|
},
|
|
1067
1073
|
'Shrinks deep record'() {
|
|
1068
|
-
|
|
1069
|
-
const User =
|
|
1074
|
+
$mol_assert_fail(() => {
|
|
1075
|
+
const User = $mol_data_record({ wife: $mol_data_record({ age: $mol_data_number }) });
|
|
1070
1076
|
User({ wife: {} });
|
|
1071
1077
|
}, '["wife"] ["age"] undefined is not a number');
|
|
1072
1078
|
},
|
|
1073
1079
|
});
|
|
1074
1080
|
})($ || ($ = {}));
|
|
1075
|
-
//record.test.
|
|
1081
|
+
//mol/data/record/record.test.ts
|
|
1076
1082
|
;
|
|
1077
1083
|
"use strict";
|
|
1078
1084
|
var $;
|
|
1079
1085
|
(function ($) {
|
|
1080
|
-
|
|
1086
|
+
$mol_test({
|
|
1081
1087
|
'Is first'() {
|
|
1082
|
-
|
|
1088
|
+
$mol_data_variant($mol_data_number, $mol_data_string)(0);
|
|
1083
1089
|
},
|
|
1084
1090
|
'Is second'() {
|
|
1085
|
-
|
|
1091
|
+
$mol_data_variant($mol_data_number, $mol_data_string)('');
|
|
1086
1092
|
},
|
|
1087
1093
|
'Is false'() {
|
|
1088
|
-
|
|
1089
|
-
|
|
1094
|
+
$mol_assert_fail(() => {
|
|
1095
|
+
$mol_data_variant($mol_data_number, $mol_data_string)(false);
|
|
1090
1096
|
}, 'false is not any of variants\nfalse is not a number\nfalse is not a string');
|
|
1091
1097
|
},
|
|
1092
1098
|
});
|
|
1093
1099
|
})($ || ($ = {}));
|
|
1094
|
-
//variant.test.
|
|
1100
|
+
//mol/data/variant/variant.test.ts
|
|
1095
1101
|
;
|
|
1096
1102
|
"use strict";
|
|
1097
1103
|
var $;
|
|
@@ -1126,36 +1132,36 @@ var $;
|
|
|
1126
1132
|
}
|
|
1127
1133
|
$.$mol_time_base = $mol_time_base;
|
|
1128
1134
|
})($ || ($ = {}));
|
|
1129
|
-
//base.
|
|
1135
|
+
//mol/time/base/base.ts
|
|
1130
1136
|
;
|
|
1131
1137
|
"use strict";
|
|
1132
1138
|
var $;
|
|
1133
1139
|
(function ($) {
|
|
1134
|
-
|
|
1140
|
+
$mol_test({
|
|
1135
1141
|
'parse and serial'() {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1142
|
+
$mol_assert_equal(new $mol_time_duration('P42.1Y').toString(), 'P42.1YT');
|
|
1143
|
+
$mol_assert_equal(new $mol_time_duration('P42.1M').toString(), 'P42.1MT');
|
|
1144
|
+
$mol_assert_equal(new $mol_time_duration('P42.1D').toString(), 'P42.1DT');
|
|
1145
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1h').toString(), 'PT42.1H');
|
|
1146
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1m').toString(), 'PT42.1M');
|
|
1147
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1s').toString(), 'PT42.1S');
|
|
1148
|
+
$mol_assert_equal(new $mol_time_duration('P1Y2M3DT4h5m6.7s').toString(), 'P1Y2M3DT4H5M6.7S');
|
|
1143
1149
|
},
|
|
1144
1150
|
'format typed'() {
|
|
1145
|
-
|
|
1151
|
+
$mol_assert_equal(new $mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
1146
1152
|
},
|
|
1147
1153
|
'comparison'() {
|
|
1148
1154
|
const iso = 'P1Y1M1DT1h1m1s';
|
|
1149
|
-
|
|
1155
|
+
$mol_assert_like(new $mol_time_duration(iso), new $mol_time_duration(iso));
|
|
1150
1156
|
},
|
|
1151
1157
|
});
|
|
1152
1158
|
})($ || ($ = {}));
|
|
1153
|
-
//duration.test.
|
|
1159
|
+
//mol/time/duration/duration.test.ts
|
|
1154
1160
|
;
|
|
1155
1161
|
"use strict";
|
|
1156
1162
|
var $;
|
|
1157
1163
|
(function ($) {
|
|
1158
|
-
class $mol_time_duration extends
|
|
1164
|
+
class $mol_time_duration extends $mol_time_base {
|
|
1159
1165
|
constructor(config = 0) {
|
|
1160
1166
|
super();
|
|
1161
1167
|
if (typeof config === 'number') {
|
|
@@ -1285,64 +1291,64 @@ var $;
|
|
|
1285
1291
|
}
|
|
1286
1292
|
$.$mol_time_duration = $mol_time_duration;
|
|
1287
1293
|
})($ || ($ = {}));
|
|
1288
|
-
//duration.
|
|
1294
|
+
//mol/time/duration/duration.ts
|
|
1289
1295
|
;
|
|
1290
1296
|
"use strict";
|
|
1291
|
-
//param.test.
|
|
1297
|
+
//mol/type/param/param.test.ts
|
|
1292
1298
|
;
|
|
1293
1299
|
"use strict";
|
|
1294
|
-
//tail.test.
|
|
1300
|
+
//mol/type/tail/tail.test.ts
|
|
1295
1301
|
;
|
|
1296
1302
|
"use strict";
|
|
1297
1303
|
var $;
|
|
1298
1304
|
(function ($) {
|
|
1299
|
-
|
|
1305
|
+
$mol_test({
|
|
1300
1306
|
'function'() {
|
|
1301
|
-
|
|
1307
|
+
$mol_assert_not($mol_func_is_class(function () { }));
|
|
1302
1308
|
},
|
|
1303
1309
|
'generator'() {
|
|
1304
|
-
|
|
1310
|
+
$mol_assert_not($mol_func_is_class(function* () { }));
|
|
1305
1311
|
},
|
|
1306
1312
|
'async'() {
|
|
1307
|
-
|
|
1313
|
+
$mol_assert_not($mol_func_is_class(async function () { }));
|
|
1308
1314
|
},
|
|
1309
1315
|
'arrow'() {
|
|
1310
|
-
|
|
1316
|
+
$mol_assert_not($mol_func_is_class(() => null));
|
|
1311
1317
|
},
|
|
1312
1318
|
'named class'() {
|
|
1313
|
-
|
|
1319
|
+
$mol_assert_ok($mol_func_is_class(class Foo {
|
|
1314
1320
|
}));
|
|
1315
1321
|
},
|
|
1316
1322
|
'unnamed class'() {
|
|
1317
|
-
|
|
1323
|
+
$mol_assert_ok($mol_func_is_class(class {
|
|
1318
1324
|
}));
|
|
1319
1325
|
},
|
|
1320
1326
|
});
|
|
1321
1327
|
})($ || ($ = {}));
|
|
1322
|
-
//class.test.
|
|
1328
|
+
//mol/func/is/class/class.test.ts
|
|
1323
1329
|
;
|
|
1324
1330
|
"use strict";
|
|
1325
|
-
//result.test.
|
|
1331
|
+
//mol/type/result/result.test.ts
|
|
1326
1332
|
;
|
|
1327
1333
|
"use strict";
|
|
1328
|
-
//foot.test.
|
|
1334
|
+
//mol/type/foot/foot.test.ts
|
|
1329
1335
|
;
|
|
1330
1336
|
"use strict";
|
|
1331
1337
|
var $;
|
|
1332
1338
|
(function ($) {
|
|
1333
|
-
|
|
1339
|
+
$mol_test({
|
|
1334
1340
|
'single function'() {
|
|
1335
|
-
const stringify =
|
|
1336
|
-
|
|
1341
|
+
const stringify = $mol_data_pipe((input) => input.toString());
|
|
1342
|
+
$mol_assert_equal(stringify(5), '5');
|
|
1337
1343
|
},
|
|
1338
1344
|
'two functions'() {
|
|
1339
|
-
const isLong =
|
|
1340
|
-
|
|
1341
|
-
|
|
1345
|
+
const isLong = $mol_data_pipe((input) => input.toString(), (input) => input.length > 2);
|
|
1346
|
+
$mol_assert_equal(isLong(5.0), false);
|
|
1347
|
+
$mol_assert_equal(isLong(5.1), true);
|
|
1342
1348
|
},
|
|
1343
1349
|
'three functions'() {
|
|
1344
|
-
const pattern =
|
|
1345
|
-
|
|
1350
|
+
const pattern = $mol_data_pipe((input) => input.toString(), (input) => new RegExp(input), (input) => input.toString());
|
|
1351
|
+
$mol_assert_equal(pattern(5), '/5/');
|
|
1346
1352
|
},
|
|
1347
1353
|
'classes'() {
|
|
1348
1354
|
class Box {
|
|
@@ -1351,26 +1357,26 @@ var $;
|
|
|
1351
1357
|
this.value = value;
|
|
1352
1358
|
}
|
|
1353
1359
|
}
|
|
1354
|
-
const boxify =
|
|
1355
|
-
|
|
1356
|
-
|
|
1360
|
+
const boxify = $mol_data_pipe((input) => input.toString(), Box);
|
|
1361
|
+
$mol_assert_ok(boxify(5) instanceof Box);
|
|
1362
|
+
$mol_assert_like(boxify(5).value, '5');
|
|
1357
1363
|
},
|
|
1358
1364
|
});
|
|
1359
1365
|
})($ || ($ = {}));
|
|
1360
|
-
//pipe.test.
|
|
1366
|
+
//mol/data/pipe/pipe.test.ts
|
|
1361
1367
|
;
|
|
1362
1368
|
"use strict";
|
|
1363
1369
|
var $;
|
|
1364
1370
|
(function ($) {
|
|
1365
|
-
|
|
1371
|
+
$mol_test({
|
|
1366
1372
|
'(De)Serialization'() {
|
|
1367
|
-
const Duration =
|
|
1368
|
-
|
|
1369
|
-
|
|
1373
|
+
const Duration = $mol_data_wrapper($mol_data_variant($mol_data_string, $mol_data_integer), $mol_time_duration);
|
|
1374
|
+
$mol_assert_equal(JSON.stringify(Duration('P1D')), '"P1DT"');
|
|
1375
|
+
$mol_assert_equal(JSON.stringify(Duration(1000)), '"PT1S"');
|
|
1370
1376
|
},
|
|
1371
1377
|
});
|
|
1372
1378
|
})($ || ($ = {}));
|
|
1373
|
-
//wrapper.test.
|
|
1379
|
+
//mol/data/wrapper/wrapper.test.ts
|
|
1374
1380
|
;
|
|
1375
1381
|
"use strict";
|
|
1376
1382
|
var $;
|
|
@@ -1394,18 +1400,18 @@ var $;
|
|
|
1394
1400
|
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1395
1401
|
$.$mol_log3_stack = [];
|
|
1396
1402
|
})($ || ($ = {}));
|
|
1397
|
-
//log3.
|
|
1403
|
+
//mol/log3/log3.ts
|
|
1398
1404
|
;
|
|
1399
1405
|
"use strict";
|
|
1400
|
-
//extract.test.
|
|
1406
|
+
//mol/type/keys/extract/extract.test.ts
|
|
1401
1407
|
;
|
|
1402
1408
|
"use strict";
|
|
1403
|
-
//extract.
|
|
1409
|
+
//mol/type/keys/extract/extract.ts
|
|
1404
1410
|
;
|
|
1405
1411
|
"use strict";
|
|
1406
1412
|
var $;
|
|
1407
1413
|
(function ($_1) {
|
|
1408
|
-
$
|
|
1414
|
+
$mol_test_mocks.push($ => {
|
|
1409
1415
|
$.$mol_log3_come = () => { };
|
|
1410
1416
|
$.$mol_log3_done = () => { };
|
|
1411
1417
|
$.$mol_log3_fail = () => { };
|
|
@@ -1414,7 +1420,7 @@ var $;
|
|
|
1414
1420
|
$.$mol_log3_area = () => () => { };
|
|
1415
1421
|
});
|
|
1416
1422
|
})($ || ($ = {}));
|
|
1417
|
-
//log3.test.
|
|
1423
|
+
//mol/log3/log3.test.ts
|
|
1418
1424
|
;
|
|
1419
1425
|
"use strict";
|
|
1420
1426
|
var $;
|
|
@@ -1443,6 +1449,6 @@ var $;
|
|
|
1443
1449
|
$.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
|
|
1444
1450
|
$.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
|
|
1445
1451
|
})($ || ($ = {}));
|
|
1446
|
-
//log3.web.
|
|
1452
|
+
//mol/log3/log3.web.ts
|
|
1447
1453
|
|
|
1448
1454
|
//# sourceMappingURL=web.test.js.map
|