mol_time_all 1.1.21 → 1.1.25
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.test.js +106 -217
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +106 -217
- package/web.test.js.map +1 -1
package/package.json
CHANGED
package/web.test.js
CHANGED
|
@@ -349,23 +349,16 @@ var $;
|
|
|
349
349
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
350
350
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
351
351
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
352
|
-
},
|
|
353
|
-
'Number'() {
|
|
354
352
|
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
355
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
356
353
|
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
357
354
|
},
|
|
358
|
-
'
|
|
355
|
+
'POJO'() {
|
|
359
356
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
360
|
-
},
|
|
361
|
-
'different POJOs'() {
|
|
362
357
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
363
|
-
},
|
|
364
|
-
'different POJOs with same keys but different values'() {
|
|
365
358
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
366
|
-
},
|
|
367
|
-
'different POJOs with different keys but same values'() {
|
|
368
359
|
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
360
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
361
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
369
362
|
},
|
|
370
363
|
'Array'() {
|
|
371
364
|
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
@@ -373,17 +366,12 @@ var $;
|
|
|
373
366
|
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
374
367
|
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
375
368
|
},
|
|
376
|
-
'
|
|
377
|
-
|
|
378
|
-
},
|
|
379
|
-
'different classes with same values'() {
|
|
380
|
-
class Obj {
|
|
381
|
-
foo = 1;
|
|
369
|
+
'Non POJO are different'() {
|
|
370
|
+
class Thing extends Object {
|
|
382
371
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
372
|
+
$.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
|
|
373
|
+
$.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
|
|
374
|
+
$.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
387
375
|
},
|
|
388
376
|
'same POJOs with cyclic reference'() {
|
|
389
377
|
const a = { foo: {} };
|
|
@@ -392,41 +380,6 @@ var $;
|
|
|
392
380
|
b['self'] = b;
|
|
393
381
|
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
394
382
|
},
|
|
395
|
-
'empty Element'() {
|
|
396
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
397
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
398
|
-
},
|
|
399
|
-
'Element with attributes'() {
|
|
400
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
401
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
402
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
403
|
-
},
|
|
404
|
-
'Element with styles'() {
|
|
405
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
406
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
407
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
408
|
-
},
|
|
409
|
-
'Element with content'() {
|
|
410
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
411
|
-
"foo",
|
|
412
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
413
|
-
"foo",
|
|
414
|
-
$.$mol_jsx("br", null))));
|
|
415
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
416
|
-
"foo",
|
|
417
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
418
|
-
"bar",
|
|
419
|
-
$.$mol_jsx("br", null))));
|
|
420
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
421
|
-
"foo",
|
|
422
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
423
|
-
"foo",
|
|
424
|
-
$.$mol_jsx("hr", null))));
|
|
425
|
-
},
|
|
426
|
-
'Element with handlers'() {
|
|
427
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
428
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
429
|
-
},
|
|
430
383
|
'Date'() {
|
|
431
384
|
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
432
385
|
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
@@ -438,8 +391,9 @@ var $;
|
|
|
438
391
|
},
|
|
439
392
|
'Map'() {
|
|
440
393
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
441
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
394
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
442
395
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
396
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
443
397
|
},
|
|
444
398
|
'Set'() {
|
|
445
399
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -458,97 +412,118 @@ var $;
|
|
|
458
412
|
"use strict";
|
|
459
413
|
var $;
|
|
460
414
|
(function ($) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
function $mol_compare_deep(a, b) {
|
|
465
|
-
if (Object.is(a, b))
|
|
415
|
+
let cache = new WeakMap();
|
|
416
|
+
function $mol_compare_deep(left, right) {
|
|
417
|
+
if (Object.is(left, right))
|
|
466
418
|
return true;
|
|
467
|
-
|
|
468
|
-
const b_type = typeof b;
|
|
469
|
-
if (a_type !== b_type)
|
|
419
|
+
if (left === null)
|
|
470
420
|
return false;
|
|
471
|
-
if (
|
|
472
|
-
return a['toString']() === b['toString']();
|
|
473
|
-
if (a_type !== 'object')
|
|
421
|
+
if (right === null)
|
|
474
422
|
return false;
|
|
475
|
-
if (
|
|
423
|
+
if (typeof left !== 'object')
|
|
476
424
|
return false;
|
|
477
|
-
if (
|
|
425
|
+
if (typeof right !== 'object')
|
|
478
426
|
return false;
|
|
479
|
-
|
|
427
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
428
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
429
|
+
if (left_proto !== right_proto)
|
|
480
430
|
return false;
|
|
481
|
-
if (
|
|
482
|
-
return
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
if (
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
431
|
+
if (left instanceof Boolean)
|
|
432
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
433
|
+
if (left instanceof Number)
|
|
434
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
435
|
+
if (left instanceof String)
|
|
436
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
437
|
+
if (left instanceof Date)
|
|
438
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
439
|
+
if (left instanceof RegExp)
|
|
440
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
441
|
+
let left_cache = cache.get(left);
|
|
442
|
+
if (left_cache) {
|
|
443
|
+
const right_cache = left_cache.get(right);
|
|
444
|
+
if (typeof right_cache === 'boolean')
|
|
445
|
+
return right_cache;
|
|
494
446
|
}
|
|
495
447
|
else {
|
|
496
|
-
|
|
497
|
-
cache.set(
|
|
448
|
+
left_cache = new WeakMap([[right, true]]);
|
|
449
|
+
cache.set(left, left_cache);
|
|
498
450
|
}
|
|
499
|
-
a_stack.push(a);
|
|
500
|
-
b_stack.push(b);
|
|
501
451
|
let result;
|
|
502
452
|
try {
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
return result = true;
|
|
517
|
-
}
|
|
518
|
-
let count = 0;
|
|
519
|
-
for (let key in a) {
|
|
520
|
-
try {
|
|
521
|
-
if (!$mol_compare_deep(a[key], b[key]))
|
|
522
|
-
return result = false;
|
|
523
|
-
}
|
|
524
|
-
catch (error) {
|
|
525
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
|
|
526
|
-
}
|
|
527
|
-
++count;
|
|
528
|
-
}
|
|
529
|
-
for (let key in b) {
|
|
530
|
-
--count;
|
|
531
|
-
if (count < 0)
|
|
532
|
-
return result = false;
|
|
533
|
-
}
|
|
534
|
-
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
535
|
-
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
536
|
-
return result = false;
|
|
537
|
-
}
|
|
538
|
-
return result = true;
|
|
453
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
454
|
+
result = compare_pojo(left, right);
|
|
455
|
+
else if (Array.isArray(left))
|
|
456
|
+
result = compare_array(left, right);
|
|
457
|
+
else if (left instanceof Set)
|
|
458
|
+
result = compare_set(left, right);
|
|
459
|
+
else if (left instanceof Map)
|
|
460
|
+
result = compare_map(left, right);
|
|
461
|
+
else if (ArrayBuffer.isView(left))
|
|
462
|
+
result = compare_buffer(left, right);
|
|
463
|
+
else
|
|
464
|
+
result = false;
|
|
539
465
|
}
|
|
540
466
|
finally {
|
|
541
|
-
|
|
542
|
-
b_stack.pop();
|
|
543
|
-
if (a_stack.length === 0) {
|
|
544
|
-
cache = null;
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
a_cache.set(b, result);
|
|
548
|
-
}
|
|
467
|
+
left_cache.set(right, result);
|
|
549
468
|
}
|
|
469
|
+
return result;
|
|
550
470
|
}
|
|
551
471
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
472
|
+
function compare_array(left, right) {
|
|
473
|
+
const len = left.length;
|
|
474
|
+
if (len !== right.length)
|
|
475
|
+
return false;
|
|
476
|
+
for (let i = 0; i < len; ++i) {
|
|
477
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
return true;
|
|
481
|
+
}
|
|
482
|
+
function compare_buffer(left, right) {
|
|
483
|
+
const len = left.byteLength;
|
|
484
|
+
if (len !== right.byteLength)
|
|
485
|
+
return false;
|
|
486
|
+
for (let i = 0; i < len; ++i) {
|
|
487
|
+
if (left[i] !== right[i])
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
function compare_iterator(left, right, compare) {
|
|
493
|
+
while (true) {
|
|
494
|
+
const left_next = left.next();
|
|
495
|
+
const right_next = right.next();
|
|
496
|
+
if (left_next.done !== right_next.done)
|
|
497
|
+
return false;
|
|
498
|
+
if (left_next.done)
|
|
499
|
+
break;
|
|
500
|
+
if (!compare(left_next.value, right_next.value))
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
function compare_set(left, right) {
|
|
506
|
+
if (left.size !== right.size)
|
|
507
|
+
return false;
|
|
508
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
509
|
+
}
|
|
510
|
+
function compare_map(left, right) {
|
|
511
|
+
if (left.size !== right.size)
|
|
512
|
+
return false;
|
|
513
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
514
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
515
|
+
}
|
|
516
|
+
function compare_pojo(left, right) {
|
|
517
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
518
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
519
|
+
if (left_keys.length !== right_keys.length)
|
|
520
|
+
return false;
|
|
521
|
+
for (let key of left_keys) {
|
|
522
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
552
527
|
})($ || ($ = {}));
|
|
553
528
|
//deep.js.map
|
|
554
529
|
;
|
|
@@ -841,91 +816,5 @@ var $;
|
|
|
841
816
|
;
|
|
842
817
|
"use strict";
|
|
843
818
|
//equals.js.map
|
|
844
|
-
;
|
|
845
|
-
"use strict";
|
|
846
|
-
var $;
|
|
847
|
-
(function ($) {
|
|
848
|
-
$.$mol_test({
|
|
849
|
-
'equal paths'() {
|
|
850
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
851
|
-
$.$mol_assert_like(diff, {
|
|
852
|
-
prefix: [1, 2, 3, 4],
|
|
853
|
-
suffix: [[], [], []],
|
|
854
|
-
});
|
|
855
|
-
},
|
|
856
|
-
'different suffix'() {
|
|
857
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
858
|
-
$.$mol_assert_like(diff, {
|
|
859
|
-
prefix: [1, 2],
|
|
860
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
861
|
-
});
|
|
862
|
-
},
|
|
863
|
-
'one contains other'() {
|
|
864
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
865
|
-
$.$mol_assert_like(diff, {
|
|
866
|
-
prefix: [1, 2],
|
|
867
|
-
suffix: [[3, 4], [], [3]],
|
|
868
|
-
});
|
|
869
|
-
},
|
|
870
|
-
'fully different'() {
|
|
871
|
-
const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
872
|
-
$.$mol_assert_like(diff, {
|
|
873
|
-
prefix: [],
|
|
874
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
875
|
-
});
|
|
876
|
-
},
|
|
877
|
-
});
|
|
878
|
-
})($ || ($ = {}));
|
|
879
|
-
//path.test.js.map
|
|
880
|
-
;
|
|
881
|
-
"use strict";
|
|
882
|
-
var $;
|
|
883
|
-
(function ($) {
|
|
884
|
-
function $mol_diff_path(...paths) {
|
|
885
|
-
const limit = Math.min(...paths.map(path => path.length));
|
|
886
|
-
lookup: for (var i = 0; i < limit; ++i) {
|
|
887
|
-
const first = paths[0][i];
|
|
888
|
-
for (let j = 1; j < paths.length; ++j) {
|
|
889
|
-
if (paths[j][i] !== first)
|
|
890
|
-
break lookup;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
return {
|
|
894
|
-
prefix: paths[0].slice(0, i),
|
|
895
|
-
suffix: paths.map(path => path.slice(i)),
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
$.$mol_diff_path = $mol_diff_path;
|
|
899
|
-
})($ || ($ = {}));
|
|
900
|
-
//path.js.map
|
|
901
|
-
;
|
|
902
|
-
"use strict";
|
|
903
|
-
var $;
|
|
904
|
-
(function ($) {
|
|
905
|
-
class $mol_error_mix extends Error {
|
|
906
|
-
errors;
|
|
907
|
-
constructor(message, ...errors) {
|
|
908
|
-
super(message);
|
|
909
|
-
this.errors = errors;
|
|
910
|
-
if (errors.length) {
|
|
911
|
-
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
912
|
-
const diff = $.$mol_diff_path(...stacks.map(stack => {
|
|
913
|
-
if (!stack)
|
|
914
|
-
return [];
|
|
915
|
-
return stack.split('\n').reverse();
|
|
916
|
-
}));
|
|
917
|
-
const head = diff.prefix.reverse().join('\n');
|
|
918
|
-
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
919
|
-
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
920
|
-
this.message += errors.map(error => '\n' + error.message).join('');
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
toJSON() {
|
|
924
|
-
return this.message;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
928
|
-
})($ || ($ = {}));
|
|
929
|
-
//mix.js.map
|
|
930
819
|
|
|
931
820
|
//# sourceMappingURL=web.test.js.map
|