mol_db 0.0.920 → 0.0.922

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_db",
3
- "version": "0.0.920",
3
+ "version": "0.0.922",
4
4
  "exports": {
5
5
  "node": {
6
6
  "import": "./node.mjs",
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/dom/context/context.ts","mol/dom/context/context.web.ts","mol/db/response/response.ts","mol/db/store/store.ts","mol/db/store/store_schema.ts","mol/db/index/index.ts","mol/db/index/index_schema.ts","mol/db/db.ts","mol/db/README.md","mol/db/db_schema.ts","mol/db/database/database.ts","mol/db/transaction/transaction.ts"],"mods":{},"deps_in":{"mol":{"mol/db":-9007199254740991,"mol/dom":-9007199254740991},"":{"mol":-9007199254740991},"mol/db/transaction":{},"mol/db":{"mol/db/transaction":-1,"mol/db/database":-1},"mol/db/store":{"mol/db/transaction":-5,"mol/db/index":-3,"mol/db":-1},"mol/db/index":{"mol/db":-5},"mol/db/response":{"mol/db/index":-3,"mol/db/store":-3,"mol/db/database":-3,"mol/db":-2},"mol/db/database":{"mol/db/transaction":-3},"mol/dom/context":{"mol/db/database":-3,"mol/db":-2},"mol/dom":{"mol/dom/context":-9007199254740991},"mol/dom/context/context.ts":{"mol/dom/context":0}},"deps_out":{"mol/db":{"mol":-9007199254740991,"mol/dom/context":-2,"mol/db/response":-2,"mol/db/store":-1,"mol/db/index":-5},"mol":{"":-9007199254740991},"mol/db/transaction":{"mol/db":-1,"mol/db/store":-5,"mol/db/database":-3},"mol/db/store":{"mol/db/response":-3},"mol/db/index":{"mol/db/store":-3,"mol/db/response":-3},"mol/db/response":{},"mol/db/database":{"mol/db":-1,"mol/dom/context":-3,"mol/db/response":-3},"mol/dom/context":{"mol/dom":-9007199254740991,"mol/dom/context/context.ts":0},"mol/dom":{"mol":-9007199254740991},"mol/dom/context/context.ts":{}},"sloc":{"ts":292,"LICENSE":113,"md":627,"lock":974,"js":9,"json":92,"tree":41,"CNAME":1,"html":1},"deps":{"mol/db":{"..":-9007199254740991,"/mol/db":-1,"/mol/db/schema":-1,"/mol/db/transaction":-2,"/mol/dom/context/indexed":-2,"/mol/db/response":-2,"/mol/db/database":-2,"/mol/db/store/schema":-1},"mol":{"..":-9007199254740991},"":{},"mol/db/transaction":{"..":-9007199254740991,"/mol/db/transaction":-1,"/mol/db/schema":-1,"/mol/db/store":-5,"/mol/db/database":-3},"mol/db/store":{"..":-9007199254740991,"/mol/db/store":-1,"/mol/db/store/schema":-1,"/mol/db/index":-5,"/mol/db/transaction":-3,"/mol/db/response":-3},"mol/db/index":{"..":-9007199254740991,"/mol/db/index":-1,"/mol/db/index/schema":-1,"/mol/db/store":-3,"/mol/db/response":-3},"mol/db/response":{"..":-9007199254740991,"/mol/db/response":-1},"mol/db/database":{"..":-9007199254740991,"/mol/db/database":-1,"/mol/db/schema":-1,"/mol/db/transaction":-3,"/mol/dom/context/indexed":-3,"/mol/db/response":-3},"mol/dom/context":{"..":-9007199254740991,"/mol/dom/context":-1,"./context.ts":0},"mol/dom":{"..":-9007199254740991},"mol/dom/context/context.ts":{"/mol/dom/context":-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/dom/context/context.ts","mol/dom/context/context.web.ts","mol/db/response/response.ts","mol/db/store/store.ts","mol/db/store/store_schema.ts","mol/db/index/index.ts","mol/db/index/index_schema.ts","mol/db/db.ts","mol/db/README.md","mol/db/db_schema.ts","mol/db/database/database.ts","mol/db/transaction/transaction.ts"],"mods":{},"deps_in":{"mol":{"mol/db":-9007199254740991,"mol/dom":-9007199254740991},"":{"mol":-9007199254740991},"mol/db/transaction":{},"mol/db":{"mol/db/transaction":-1,"mol/db/database":-1},"mol/db/store":{"mol/db/transaction":-5,"mol/db/index":-3,"mol/db":-1},"mol/db/index":{"mol/db":-5},"mol/db/response":{"mol/db/index":-3,"mol/db/store":-3,"mol/db/database":-3,"mol/db":-2},"mol/db/database":{"mol/db/transaction":-3},"mol/dom/context":{"mol/db/database":-3,"mol/db":-2},"mol/dom":{"mol/dom/context":-9007199254740991},"mol/dom/context/context.ts":{"mol/dom/context":0}},"deps_out":{"mol/db":{"mol":-9007199254740991,"mol/dom/context":-2,"mol/db/response":-2,"mol/db/store":-1,"mol/db/index":-5},"mol":{"":-9007199254740991},"mol/db/transaction":{"mol/db":-1,"mol/db/store":-5,"mol/db/database":-3},"mol/db/store":{"mol/db/response":-3},"mol/db/index":{"mol/db/store":-3,"mol/db/response":-3},"mol/db/response":{},"mol/db/database":{"mol/db":-1,"mol/dom/context":-3,"mol/db/response":-3},"mol/dom/context":{"mol/dom":-9007199254740991,"mol/dom/context/context.ts":0},"mol/dom":{"mol":-9007199254740991},"mol/dom/context/context.ts":{}},"sloc":{"ts":292,"LICENSE":113,"md":627,"lock":974,"js":9,"json":93,"tree":41,"CNAME":1,"html":1},"deps":{"mol/db":{"..":-9007199254740991,"/mol/db":-1,"/mol/db/schema":-1,"/mol/db/transaction":-2,"/mol/dom/context/indexed":-2,"/mol/db/response":-2,"/mol/db/database":-2,"/mol/db/store/schema":-1},"mol":{"..":-9007199254740991},"":{},"mol/db/transaction":{"..":-9007199254740991,"/mol/db/transaction":-1,"/mol/db/schema":-1,"/mol/db/store":-5,"/mol/db/database":-3},"mol/db/store":{"..":-9007199254740991,"/mol/db/store":-1,"/mol/db/store/schema":-1,"/mol/db/index":-5,"/mol/db/transaction":-3,"/mol/db/response":-3},"mol/db/index":{"..":-9007199254740991,"/mol/db/index":-1,"/mol/db/index/schema":-1,"/mol/db/store":-3,"/mol/db/response":-3},"mol/db/response":{"..":-9007199254740991,"/mol/db/response":-1},"mol/db/database":{"..":-9007199254740991,"/mol/db/database":-1,"/mol/db/schema":-1,"/mol/db/transaction":-3,"/mol/dom/context/indexed":-3,"/mol/db/response":-3},"mol/dom/context":{"..":-9007199254740991,"/mol/dom/context":-1,"./context.ts":0},"mol/dom":{"..":-9007199254740991},"mol/dom/context/context.ts":{"/mol/dom/context":-1}}}
package/web.test.js CHANGED
@@ -426,7 +426,12 @@ var $;
426
426
  var $;
427
427
  (function ($) {
428
428
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
429
- return new Proxy(new $mol_range2_array(), {
429
+ const source = typeof item === 'function' ? new $mol_range2_array() : item;
430
+ if (typeof item !== 'function') {
431
+ item = index => source[index];
432
+ size = () => source.length;
433
+ }
434
+ return new Proxy(source, {
430
435
  get(target, field) {
431
436
  if (typeof field === 'string') {
432
437
  if (field === 'length')
@@ -439,7 +444,7 @@ var $;
439
444
  if (index === Math.trunc(index))
440
445
  return item(index);
441
446
  }
442
- return target[field];
447
+ return $mol_range2_array.prototype[field];
443
448
  },
444
449
  set(target, field) {
445
450
  return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
@@ -480,13 +485,16 @@ var $;
480
485
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
481
486
  }
482
487
  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;
488
+ const filtered = [];
489
+ let cursor = -1;
490
+ return $mol_range2(index => {
491
+ while (cursor < this.length && index >= filtered.length - 1) {
492
+ const val = this[++cursor];
493
+ if (check(val, cursor, this))
494
+ filtered.push(val);
495
+ }
496
+ return filtered[index];
497
+ }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
490
498
  }
491
499
  forEach(proceed, context) {
492
500
  for (let [key, value] of this.entries())
@@ -546,7 +554,7 @@ var $;
546
554
  'lazy calls'() {
547
555
  let calls = 0;
548
556
  const list = $mol_range2(index => (++calls, index), () => 10);
549
- $mol_assert_ok(list instanceof Array);
557
+ $mol_assert_equal(true, list instanceof Array);
550
558
  $mol_assert_equal(list.length, 10);
551
559
  $mol_assert_equal(list[-1], undefined);
552
560
  $mol_assert_equal(list[0], 0);
@@ -589,11 +597,17 @@ var $;
589
597
  $mol_range2(i => i, () => 5).forEach(i => log += i);
590
598
  $mol_assert_equal(log, '01234');
591
599
  },
600
+ 'reduce'() {
601
+ let calls = 0;
602
+ const list = $mol_range2().slice(1, 6);
603
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
604
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
605
+ },
592
606
  'lazy concat'() {
593
607
  let calls1 = 0;
594
608
  let calls2 = 0;
595
609
  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);
610
+ $mol_assert_equal(true, list instanceof Array);
597
611
  $mol_assert_equal(list.length, 15);
598
612
  $mol_assert_equal(list[0], 0);
599
613
  $mol_assert_equal(list[4], 4);
@@ -605,32 +619,26 @@ var $;
605
619
  $mol_assert_equal(calls1, 2);
606
620
  $mol_assert_equal(calls2, 2);
607
621
  },
608
- 'filter'() {
622
+ 'lazy filter'() {
609
623
  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);
624
+ const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
625
+ $mol_assert_equal(true, list instanceof Array);
612
626
  $mol_assert_equal(list.length, 3);
613
627
  $mol_assert_equal(list[0], 1);
614
628
  $mol_assert_equal(list[2], 5);
615
629
  $mol_assert_equal(list[3], undefined);
616
- $mol_assert_equal(calls, 10);
630
+ $mol_assert_equal(calls, 8);
617
631
  },
618
- 'reverse'() {
632
+ 'lazy reverse'() {
619
633
  let calls = 0;
620
634
  const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
621
- $mol_assert_ok(list instanceof Array);
635
+ $mol_assert_equal(true, list instanceof Array);
622
636
  $mol_assert_equal(list.length, 3);
623
637
  $mol_assert_equal(list[0], 9);
624
638
  $mol_assert_equal(list[2], 7);
625
639
  $mol_assert_equal(list[3], undefined);
626
640
  $mol_assert_equal(calls, 2);
627
641
  },
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
642
  'lazy map'() {
635
643
  let calls1 = 0;
636
644
  let calls2 = 0;
@@ -640,7 +648,7 @@ var $;
640
648
  $mol_assert_equal(source, self);
641
649
  return index + 10;
642
650
  }, () => 5);
643
- $mol_assert_ok(target instanceof Array);
651
+ $mol_assert_equal(true, target instanceof Array);
644
652
  $mol_assert_equal(target.length, 5);
645
653
  $mol_assert_equal(target[0], 10);
646
654
  $mol_assert_equal(target[4], 14);
@@ -651,7 +659,7 @@ var $;
651
659
  'lazy slice'() {
652
660
  let calls = 0;
653
661
  const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
654
- $mol_assert_ok(list instanceof Array);
662
+ $mol_assert_equal(true, list instanceof Array);
655
663
  $mol_assert_equal(list.length, 4);
656
664
  $mol_assert_equal(list[0], 3);
657
665
  $mol_assert_equal(list[3], 6);
@@ -660,22 +668,22 @@ var $;
660
668
  },
661
669
  'lazy some'() {
662
670
  let calls = 0;
663
- $mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
671
+ $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
664
672
  $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));
673
+ $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
674
+ $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
667
675
  },
668
676
  'lazy every'() {
669
677
  let calls = 0;
670
- $mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
678
+ $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
671
679
  $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));
680
+ $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
681
+ $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
674
682
  },
675
683
  'lazyfy'() {
676
684
  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);
685
+ const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
686
+ $mol_assert_equal(true, list instanceof Array);
679
687
  $mol_assert_equal(list.length, 4);
680
688
  $mol_assert_equal(calls, 0);
681
689
  $mol_assert_equal(list[0], 12);