mol_mutable 0.0.400 → 0.0.402
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.deps.json +1 -1
- package/node.test.js +41 -33
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.test.js +41 -33
- package/web.test.js.map +1 -1
package/package.json
CHANGED
package/web.deps.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"files":["mam.ts","LICENSE","README.md","yarn.lock","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/index.html","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/type/README.md","mol/type/immutable/deep/deep/deep.ts","mol/mutable/README.md","mol/mutable/mutable.ts"],"mods":{},"deps_in":{"mol":{"mol/mutable":-9007199254740991,"mol/type":-9007199254740991},"":{"mol":-9007199254740991},"mol/type/immutable/deep/deep":{"mol/mutable":-2},"mol/type/immutable/deep":{"mol/type/immutable/deep/deep":-9007199254740991},"mol/type/immutable":{"mol/type/immutable/deep":-9007199254740991},"mol/type":{"mol/type/immutable":-9007199254740991}},"deps_out":{"mol/mutable":{"mol":-9007199254740991,"mol/type/immutable/deep/deep":-2},"mol":{"":-9007199254740991},"mol/type/immutable/deep/deep":{"mol/type/immutable/deep":-9007199254740991},"mol/type/immutable/deep":{"mol/type/immutable":-9007199254740991},"mol/type/immutable":{"mol/type":-9007199254740991},"mol/type":{"mol":-9007199254740991}},"sloc":{"ts":51,"LICENSE":113,"md":511,"lock":974,"js":9,"json":
|
|
1
|
+
{"files":["mam.ts","LICENSE","README.md","yarn.lock","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/index.html","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/type/README.md","mol/type/immutable/deep/deep/deep.ts","mol/mutable/README.md","mol/mutable/mutable.ts"],"mods":{},"deps_in":{"mol":{"mol/mutable":-9007199254740991,"mol/type":-9007199254740991},"":{"mol":-9007199254740991},"mol/type/immutable/deep/deep":{"mol/mutable":-2},"mol/type/immutable/deep":{"mol/type/immutable/deep/deep":-9007199254740991},"mol/type/immutable":{"mol/type/immutable/deep":-9007199254740991},"mol/type":{"mol/type/immutable":-9007199254740991}},"deps_out":{"mol/mutable":{"mol":-9007199254740991,"mol/type/immutable/deep/deep":-2},"mol":{"":-9007199254740991},"mol/type/immutable/deep/deep":{"mol/type/immutable/deep":-9007199254740991},"mol/type/immutable/deep":{"mol/type/immutable":-9007199254740991},"mol/type/immutable":{"mol/type":-9007199254740991},"mol/type":{"mol":-9007199254740991}},"sloc":{"ts":51,"LICENSE":113,"md":511,"lock":974,"js":9,"json":93,"tree":41,"CNAME":1,"html":1},"deps":{"mol/mutable":{"..":-9007199254740991,"/mol/mutable/wrapper":-1,"/mol/type/immutable/deep":-2,"/mol/mutable":-1},"mol":{"..":-9007199254740991},"":{},"mol/type/immutable/deep/deep":{"..":-9007199254740991,"/mol/type/immutable/deep":-1},"mol/type/immutable/deep":{"..":-9007199254740991},"mol/type/immutable":{"..":-9007199254740991},"mol/type":{"..":-9007199254740991}}}
|
package/web.test.js
CHANGED
|
@@ -448,7 +448,12 @@ var $;
|
|
|
448
448
|
var $;
|
|
449
449
|
(function ($) {
|
|
450
450
|
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
451
|
-
|
|
451
|
+
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
452
|
+
if (typeof item !== 'function') {
|
|
453
|
+
item = index => source[index];
|
|
454
|
+
size = () => source.length;
|
|
455
|
+
}
|
|
456
|
+
return new Proxy(source, {
|
|
452
457
|
get(target, field) {
|
|
453
458
|
if (typeof field === 'string') {
|
|
454
459
|
if (field === 'length')
|
|
@@ -461,7 +466,7 @@ var $;
|
|
|
461
466
|
if (index === Math.trunc(index))
|
|
462
467
|
return item(index);
|
|
463
468
|
}
|
|
464
|
-
return
|
|
469
|
+
return $mol_range2_array.prototype[field];
|
|
465
470
|
},
|
|
466
471
|
set(target, field) {
|
|
467
472
|
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
@@ -502,13 +507,16 @@ var $;
|
|
|
502
507
|
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
503
508
|
}
|
|
504
509
|
filter(check, context) {
|
|
505
|
-
const filtered =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
510
|
+
const filtered = [];
|
|
511
|
+
let cursor = -1;
|
|
512
|
+
return $mol_range2(index => {
|
|
513
|
+
while (cursor < this.length && index >= filtered.length - 1) {
|
|
514
|
+
const val = this[++cursor];
|
|
515
|
+
if (check(val, cursor, this))
|
|
516
|
+
filtered.push(val);
|
|
517
|
+
}
|
|
518
|
+
return filtered[index];
|
|
519
|
+
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
512
520
|
}
|
|
513
521
|
forEach(proceed, context) {
|
|
514
522
|
for (let [key, value] of this.entries())
|
|
@@ -568,7 +576,7 @@ var $;
|
|
|
568
576
|
'lazy calls'() {
|
|
569
577
|
let calls = 0;
|
|
570
578
|
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
571
|
-
$
|
|
579
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
572
580
|
$mol_assert_equal(list.length, 10);
|
|
573
581
|
$mol_assert_equal(list[-1], undefined);
|
|
574
582
|
$mol_assert_equal(list[0], 0);
|
|
@@ -611,11 +619,17 @@ var $;
|
|
|
611
619
|
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
612
620
|
$mol_assert_equal(log, '01234');
|
|
613
621
|
},
|
|
622
|
+
'reduce'() {
|
|
623
|
+
let calls = 0;
|
|
624
|
+
const list = $mol_range2().slice(1, 6);
|
|
625
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
626
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
627
|
+
},
|
|
614
628
|
'lazy concat'() {
|
|
615
629
|
let calls1 = 0;
|
|
616
630
|
let calls2 = 0;
|
|
617
631
|
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
618
|
-
$
|
|
632
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
619
633
|
$mol_assert_equal(list.length, 15);
|
|
620
634
|
$mol_assert_equal(list[0], 0);
|
|
621
635
|
$mol_assert_equal(list[4], 4);
|
|
@@ -627,32 +641,26 @@ var $;
|
|
|
627
641
|
$mol_assert_equal(calls1, 2);
|
|
628
642
|
$mol_assert_equal(calls2, 2);
|
|
629
643
|
},
|
|
630
|
-
'filter'() {
|
|
644
|
+
'lazy filter'() {
|
|
631
645
|
let calls = 0;
|
|
632
|
-
const list = $mol_range2(index => (++calls, index), () =>
|
|
633
|
-
$
|
|
646
|
+
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
|
647
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
634
648
|
$mol_assert_equal(list.length, 3);
|
|
635
649
|
$mol_assert_equal(list[0], 1);
|
|
636
650
|
$mol_assert_equal(list[2], 5);
|
|
637
651
|
$mol_assert_equal(list[3], undefined);
|
|
638
|
-
$mol_assert_equal(calls,
|
|
652
|
+
$mol_assert_equal(calls, 8);
|
|
639
653
|
},
|
|
640
|
-
'reverse'() {
|
|
654
|
+
'lazy reverse'() {
|
|
641
655
|
let calls = 0;
|
|
642
656
|
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
643
|
-
$
|
|
657
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
644
658
|
$mol_assert_equal(list.length, 3);
|
|
645
659
|
$mol_assert_equal(list[0], 9);
|
|
646
660
|
$mol_assert_equal(list[2], 7);
|
|
647
661
|
$mol_assert_equal(list[3], undefined);
|
|
648
662
|
$mol_assert_equal(calls, 2);
|
|
649
663
|
},
|
|
650
|
-
'reduce'() {
|
|
651
|
-
let calls = 0;
|
|
652
|
-
const list = $mol_range2().slice(1, 6);
|
|
653
|
-
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
654
|
-
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
655
|
-
},
|
|
656
664
|
'lazy map'() {
|
|
657
665
|
let calls1 = 0;
|
|
658
666
|
let calls2 = 0;
|
|
@@ -662,7 +670,7 @@ var $;
|
|
|
662
670
|
$mol_assert_equal(source, self);
|
|
663
671
|
return index + 10;
|
|
664
672
|
}, () => 5);
|
|
665
|
-
$
|
|
673
|
+
$mol_assert_equal(true, target instanceof Array);
|
|
666
674
|
$mol_assert_equal(target.length, 5);
|
|
667
675
|
$mol_assert_equal(target[0], 10);
|
|
668
676
|
$mol_assert_equal(target[4], 14);
|
|
@@ -673,7 +681,7 @@ var $;
|
|
|
673
681
|
'lazy slice'() {
|
|
674
682
|
let calls = 0;
|
|
675
683
|
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
676
|
-
$
|
|
684
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
677
685
|
$mol_assert_equal(list.length, 4);
|
|
678
686
|
$mol_assert_equal(list[0], 3);
|
|
679
687
|
$mol_assert_equal(list[3], 6);
|
|
@@ -682,22 +690,22 @@ var $;
|
|
|
682
690
|
},
|
|
683
691
|
'lazy some'() {
|
|
684
692
|
let calls = 0;
|
|
685
|
-
$
|
|
693
|
+
$mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
686
694
|
$mol_assert_equal(calls, 3);
|
|
687
|
-
$
|
|
688
|
-
$
|
|
695
|
+
$mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
|
|
696
|
+
$mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
|
|
689
697
|
},
|
|
690
698
|
'lazy every'() {
|
|
691
699
|
let calls = 0;
|
|
692
|
-
$
|
|
700
|
+
$mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
693
701
|
$mol_assert_equal(calls, 3);
|
|
694
|
-
$
|
|
695
|
-
$
|
|
702
|
+
$mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
|
|
703
|
+
$mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
|
|
696
704
|
},
|
|
697
705
|
'lazyfy'() {
|
|
698
706
|
let calls = 0;
|
|
699
|
-
const list =
|
|
700
|
-
$
|
|
707
|
+
const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
708
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
701
709
|
$mol_assert_equal(list.length, 4);
|
|
702
710
|
$mol_assert_equal(calls, 0);
|
|
703
711
|
$mol_assert_equal(list[0], 12);
|