mol_db 0.0.795 → 0.0.797
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 +296 -2
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +296 -2
- package/web.test.js.map +1 -1
package/package.json
CHANGED
package/web.test.js
CHANGED
|
@@ -409,6 +409,298 @@ var $;
|
|
|
409
409
|
;
|
|
410
410
|
"use strict";
|
|
411
411
|
var $;
|
|
412
|
+
(function ($) {
|
|
413
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
414
|
+
for (;;) {
|
|
415
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
416
|
+
if (exists(id))
|
|
417
|
+
continue;
|
|
418
|
+
return id;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
$.$mol_guid = $mol_guid;
|
|
422
|
+
})($ || ($ = {}));
|
|
423
|
+
//mol/guid/guid.ts
|
|
424
|
+
;
|
|
425
|
+
"use strict";
|
|
426
|
+
var $;
|
|
427
|
+
(function ($) {
|
|
428
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
429
|
+
return new Proxy(new $mol_range2_array(), {
|
|
430
|
+
get(target, field) {
|
|
431
|
+
if (typeof field === 'string') {
|
|
432
|
+
if (field === 'length')
|
|
433
|
+
return size();
|
|
434
|
+
const index = Number(field);
|
|
435
|
+
if (index < 0)
|
|
436
|
+
return undefined;
|
|
437
|
+
if (index >= size())
|
|
438
|
+
return undefined;
|
|
439
|
+
if (index === Math.trunc(index))
|
|
440
|
+
return item(index);
|
|
441
|
+
}
|
|
442
|
+
return target[field];
|
|
443
|
+
},
|
|
444
|
+
set(target, field) {
|
|
445
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
446
|
+
},
|
|
447
|
+
ownKeys(target) {
|
|
448
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
449
|
+
},
|
|
450
|
+
getOwnPropertyDescriptor(target, field) {
|
|
451
|
+
if (field === "length")
|
|
452
|
+
return {
|
|
453
|
+
value: size(),
|
|
454
|
+
writable: true,
|
|
455
|
+
enumerable: false,
|
|
456
|
+
configurable: false,
|
|
457
|
+
};
|
|
458
|
+
const index = Number(field);
|
|
459
|
+
if (index === Math.trunc(index))
|
|
460
|
+
return {
|
|
461
|
+
get: () => this.get(target, field, this),
|
|
462
|
+
enumerable: true,
|
|
463
|
+
configurable: true,
|
|
464
|
+
};
|
|
465
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
$.$mol_range2 = $mol_range2;
|
|
470
|
+
class $mol_range2_array extends Array {
|
|
471
|
+
concat(...tail) {
|
|
472
|
+
if (tail.length === 0)
|
|
473
|
+
return this;
|
|
474
|
+
if (tail.length > 1) {
|
|
475
|
+
let list = this;
|
|
476
|
+
for (let item of tail)
|
|
477
|
+
list = list.concat(item);
|
|
478
|
+
return list;
|
|
479
|
+
}
|
|
480
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
481
|
+
}
|
|
482
|
+
filter(check, context) {
|
|
483
|
+
const filtered = new $mol_range2_array();
|
|
484
|
+
for (let index = 0; index < this.length; ++index) {
|
|
485
|
+
const item = this[index];
|
|
486
|
+
if (check.call(context, item, index, this))
|
|
487
|
+
filtered.push(item);
|
|
488
|
+
}
|
|
489
|
+
return filtered;
|
|
490
|
+
}
|
|
491
|
+
forEach(proceed, context) {
|
|
492
|
+
for (let [key, value] of this.entries())
|
|
493
|
+
proceed.call(context, value, key, this);
|
|
494
|
+
}
|
|
495
|
+
map(proceed, context) {
|
|
496
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
497
|
+
}
|
|
498
|
+
reduce(merge, result) {
|
|
499
|
+
let index = 0;
|
|
500
|
+
if (arguments.length === 1) {
|
|
501
|
+
result = this[index++];
|
|
502
|
+
}
|
|
503
|
+
for (; index < this.length; ++index) {
|
|
504
|
+
result = merge(result, this[index], index, this);
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
toReversed() {
|
|
509
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
510
|
+
}
|
|
511
|
+
slice(from = 0, to = this.length) {
|
|
512
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
513
|
+
}
|
|
514
|
+
some(check, context) {
|
|
515
|
+
for (let index = 0; index < this.length; ++index) {
|
|
516
|
+
if (check.call(context, this[index], index, this))
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
every(check, context) {
|
|
522
|
+
for (let index = 0; index < this.length; ++index) {
|
|
523
|
+
if (!check.call(context, this[index], index, this))
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
reverse() {
|
|
529
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
530
|
+
}
|
|
531
|
+
sort() {
|
|
532
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
533
|
+
}
|
|
534
|
+
[Symbol.toPrimitive]() {
|
|
535
|
+
return $mol_guid();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
$.$mol_range2_array = $mol_range2_array;
|
|
539
|
+
})($ || ($ = {}));
|
|
540
|
+
//mol/range2/range2.ts
|
|
541
|
+
;
|
|
542
|
+
"use strict";
|
|
543
|
+
var $;
|
|
544
|
+
(function ($) {
|
|
545
|
+
$mol_test({
|
|
546
|
+
'lazy calls'() {
|
|
547
|
+
let calls = 0;
|
|
548
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
549
|
+
$mol_assert_ok(list instanceof Array);
|
|
550
|
+
$mol_assert_equal(list.length, 10);
|
|
551
|
+
$mol_assert_equal(list[-1], undefined);
|
|
552
|
+
$mol_assert_equal(list[0], 0);
|
|
553
|
+
$mol_assert_equal(list[9], 9);
|
|
554
|
+
$mol_assert_equal(list[9.5], undefined);
|
|
555
|
+
$mol_assert_equal(list[10], undefined);
|
|
556
|
+
$mol_assert_equal(calls, 2);
|
|
557
|
+
},
|
|
558
|
+
'infinity list'() {
|
|
559
|
+
let calls = 0;
|
|
560
|
+
const list = $mol_range2(index => (++calls, index));
|
|
561
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
562
|
+
$mol_assert_equal(list[0], 0);
|
|
563
|
+
$mol_assert_equal(list[4], 4);
|
|
564
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
565
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
566
|
+
$mol_assert_equal(calls, 3);
|
|
567
|
+
},
|
|
568
|
+
'stringify'() {
|
|
569
|
+
const list = $mol_range2(i => i, () => 5);
|
|
570
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
571
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
572
|
+
},
|
|
573
|
+
'for-of'() {
|
|
574
|
+
let log = '';
|
|
575
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
576
|
+
log += i;
|
|
577
|
+
}
|
|
578
|
+
$mol_assert_equal(log, '12345');
|
|
579
|
+
},
|
|
580
|
+
'for-in'() {
|
|
581
|
+
let log = '';
|
|
582
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
|
583
|
+
log += i;
|
|
584
|
+
}
|
|
585
|
+
$mol_assert_equal(log, '01234');
|
|
586
|
+
},
|
|
587
|
+
'forEach'() {
|
|
588
|
+
let log = '';
|
|
589
|
+
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
590
|
+
$mol_assert_equal(log, '01234');
|
|
591
|
+
},
|
|
592
|
+
'lazy concat'() {
|
|
593
|
+
let calls1 = 0;
|
|
594
|
+
let calls2 = 0;
|
|
595
|
+
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
596
|
+
$mol_assert_ok(list instanceof Array);
|
|
597
|
+
$mol_assert_equal(list.length, 15);
|
|
598
|
+
$mol_assert_equal(list[0], 0);
|
|
599
|
+
$mol_assert_equal(list[4], 4);
|
|
600
|
+
$mol_assert_equal(list[5], 0);
|
|
601
|
+
$mol_assert_equal(list[9], 4);
|
|
602
|
+
$mol_assert_equal(list[10], 0);
|
|
603
|
+
$mol_assert_equal(list[14], 4);
|
|
604
|
+
$mol_assert_equal(list[15], undefined);
|
|
605
|
+
$mol_assert_equal(calls1, 2);
|
|
606
|
+
$mol_assert_equal(calls2, 2);
|
|
607
|
+
},
|
|
608
|
+
'filter'() {
|
|
609
|
+
let calls = 0;
|
|
610
|
+
const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
|
|
611
|
+
$mol_assert_ok(list instanceof Array);
|
|
612
|
+
$mol_assert_equal(list.length, 3);
|
|
613
|
+
$mol_assert_equal(list[0], 1);
|
|
614
|
+
$mol_assert_equal(list[2], 5);
|
|
615
|
+
$mol_assert_equal(list[3], undefined);
|
|
616
|
+
$mol_assert_equal(calls, 10);
|
|
617
|
+
},
|
|
618
|
+
'reverse'() {
|
|
619
|
+
let calls = 0;
|
|
620
|
+
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
621
|
+
$mol_assert_ok(list instanceof Array);
|
|
622
|
+
$mol_assert_equal(list.length, 3);
|
|
623
|
+
$mol_assert_equal(list[0], 9);
|
|
624
|
+
$mol_assert_equal(list[2], 7);
|
|
625
|
+
$mol_assert_equal(list[3], undefined);
|
|
626
|
+
$mol_assert_equal(calls, 2);
|
|
627
|
+
},
|
|
628
|
+
'reduce'() {
|
|
629
|
+
let calls = 0;
|
|
630
|
+
const list = $mol_range2().slice(1, 6);
|
|
631
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
632
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
633
|
+
},
|
|
634
|
+
'lazy map'() {
|
|
635
|
+
let calls1 = 0;
|
|
636
|
+
let calls2 = 0;
|
|
637
|
+
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
638
|
+
const target = source.map((item, index, self) => {
|
|
639
|
+
++calls2;
|
|
640
|
+
$mol_assert_equal(source, self);
|
|
641
|
+
return index + 10;
|
|
642
|
+
}, () => 5);
|
|
643
|
+
$mol_assert_ok(target instanceof Array);
|
|
644
|
+
$mol_assert_equal(target.length, 5);
|
|
645
|
+
$mol_assert_equal(target[0], 10);
|
|
646
|
+
$mol_assert_equal(target[4], 14);
|
|
647
|
+
$mol_assert_equal(target[5], undefined);
|
|
648
|
+
$mol_assert_equal(calls1, 2);
|
|
649
|
+
$mol_assert_equal(calls2, 2);
|
|
650
|
+
},
|
|
651
|
+
'lazy slice'() {
|
|
652
|
+
let calls = 0;
|
|
653
|
+
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
654
|
+
$mol_assert_ok(list instanceof Array);
|
|
655
|
+
$mol_assert_equal(list.length, 4);
|
|
656
|
+
$mol_assert_equal(list[0], 3);
|
|
657
|
+
$mol_assert_equal(list[3], 6);
|
|
658
|
+
$mol_assert_equal(list[4], undefined);
|
|
659
|
+
$mol_assert_equal(calls, 2);
|
|
660
|
+
},
|
|
661
|
+
'lazy some'() {
|
|
662
|
+
let calls = 0;
|
|
663
|
+
$mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
664
|
+
$mol_assert_equal(calls, 3);
|
|
665
|
+
$mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
|
|
666
|
+
$mol_assert_ok($mol_range2(i => i).some(v => v > 5));
|
|
667
|
+
},
|
|
668
|
+
'lazy every'() {
|
|
669
|
+
let calls = 0;
|
|
670
|
+
$mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
671
|
+
$mol_assert_equal(calls, 3);
|
|
672
|
+
$mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
|
|
673
|
+
$mol_assert_not($mol_range2(i => i).every(v => v < 5));
|
|
674
|
+
},
|
|
675
|
+
'lazyfy'() {
|
|
676
|
+
let calls = 0;
|
|
677
|
+
const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
678
|
+
$mol_assert_ok(list instanceof Array);
|
|
679
|
+
$mol_assert_equal(list.length, 4);
|
|
680
|
+
$mol_assert_equal(calls, 0);
|
|
681
|
+
$mol_assert_equal(list[0], 12);
|
|
682
|
+
$mol_assert_equal(list[3], 15);
|
|
683
|
+
$mol_assert_equal(list[4], undefined);
|
|
684
|
+
$mol_assert_equal(calls, 2);
|
|
685
|
+
},
|
|
686
|
+
'prevent modification'() {
|
|
687
|
+
const list = $mol_range2(i => i, () => 5);
|
|
688
|
+
$mol_assert_fail(() => list.push(4), TypeError);
|
|
689
|
+
$mol_assert_fail(() => list.pop(), TypeError);
|
|
690
|
+
$mol_assert_fail(() => list.unshift(4), TypeError);
|
|
691
|
+
$mol_assert_fail(() => list.shift(), TypeError);
|
|
692
|
+
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
|
693
|
+
$mol_assert_fail(() => list[1] = 2, TypeError);
|
|
694
|
+
$mol_assert_fail(() => list.reverse(), TypeError);
|
|
695
|
+
$mol_assert_fail(() => list.sort(), TypeError);
|
|
696
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
})($ || ($ = {}));
|
|
700
|
+
//mol/range2/range2.test.ts
|
|
701
|
+
;
|
|
702
|
+
"use strict";
|
|
703
|
+
var $;
|
|
412
704
|
(function ($) {
|
|
413
705
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
414
706
|
function $mol_compare_deep(left, right) {
|
|
@@ -454,6 +746,8 @@ var $;
|
|
|
454
746
|
result = compare_pojo(left, right);
|
|
455
747
|
else if (!Reflect.getPrototypeOf(left_proto))
|
|
456
748
|
result = compare_pojo(left, right);
|
|
749
|
+
else if (Symbol.toPrimitive in left)
|
|
750
|
+
result = compare_primitive(left, right);
|
|
457
751
|
else if (Array.isArray(left))
|
|
458
752
|
result = compare_array(left, right);
|
|
459
753
|
else if (left instanceof Set)
|
|
@@ -464,8 +758,6 @@ var $;
|
|
|
464
758
|
result = compare_buffer(left, right);
|
|
465
759
|
else if (Symbol.iterator in left)
|
|
466
760
|
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
467
|
-
else if (Symbol.toPrimitive in left)
|
|
468
|
-
result = compare_primitive(left, right);
|
|
469
761
|
else
|
|
470
762
|
result = false;
|
|
471
763
|
}
|
|
@@ -575,6 +867,8 @@ var $;
|
|
|
575
867
|
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
576
868
|
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
577
869
|
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
870
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
871
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
578
872
|
},
|
|
579
873
|
'Non POJO are different'() {
|
|
580
874
|
class Thing extends Object {
|