mol_plot_all 1.2.753 → 1.2.754

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.mjs CHANGED
@@ -953,6 +953,8 @@ var $;
953
953
  result = compare_pojo(left, right);
954
954
  else if (!Reflect.getPrototypeOf(left_proto))
955
955
  result = compare_pojo(left, right);
956
+ else if (Symbol.toPrimitive in left)
957
+ result = compare_primitive(left, right);
956
958
  else if (Array.isArray(left))
957
959
  result = compare_array(left, right);
958
960
  else if (left instanceof Set)
@@ -963,8 +965,6 @@ var $;
963
965
  result = compare_buffer(left, right);
964
966
  else if (Symbol.iterator in left)
965
967
  result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
966
- else if (Symbol.toPrimitive in left)
967
- result = compare_primitive(left, right);
968
968
  else
969
969
  result = false;
970
970
  }
package/node.test.js CHANGED
@@ -945,6 +945,8 @@ var $;
945
945
  result = compare_pojo(left, right);
946
946
  else if (!Reflect.getPrototypeOf(left_proto))
947
947
  result = compare_pojo(left, right);
948
+ else if (Symbol.toPrimitive in left)
949
+ result = compare_primitive(left, right);
948
950
  else if (Array.isArray(left))
949
951
  result = compare_array(left, right);
950
952
  else if (left instanceof Set)
@@ -955,8 +957,6 @@ var $;
955
957
  result = compare_buffer(left, right);
956
958
  else if (Symbol.iterator in left)
957
959
  result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
958
- else if (Symbol.toPrimitive in left)
959
- result = compare_primitive(left, right);
960
960
  else
961
961
  result = false;
962
962
  }
@@ -6623,6 +6623,283 @@ var $;
6623
6623
  ;
6624
6624
  "use strict";
6625
6625
  var $;
6626
+ (function ($) {
6627
+ function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
6628
+ return new Proxy(new $mol_range2_array(), {
6629
+ get(target, field) {
6630
+ if (typeof field === 'string') {
6631
+ if (field === 'length')
6632
+ return size();
6633
+ const index = Number(field);
6634
+ if (index < 0)
6635
+ return undefined;
6636
+ if (index >= size())
6637
+ return undefined;
6638
+ if (index === Math.trunc(index))
6639
+ return item(index);
6640
+ }
6641
+ return target[field];
6642
+ },
6643
+ set(target, field) {
6644
+ return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
6645
+ },
6646
+ ownKeys(target) {
6647
+ return [...Array(size())].map((v, i) => String(i)).concat('length');
6648
+ },
6649
+ getOwnPropertyDescriptor(target, field) {
6650
+ if (field === "length")
6651
+ return {
6652
+ value: size(),
6653
+ writable: true,
6654
+ enumerable: false,
6655
+ configurable: false,
6656
+ };
6657
+ const index = Number(field);
6658
+ if (index === Math.trunc(index))
6659
+ return {
6660
+ get: () => this.get(target, field, this),
6661
+ enumerable: true,
6662
+ configurable: true,
6663
+ };
6664
+ return Object.getOwnPropertyDescriptor(target, field);
6665
+ }
6666
+ });
6667
+ }
6668
+ $.$mol_range2 = $mol_range2;
6669
+ class $mol_range2_array extends Array {
6670
+ concat(...tail) {
6671
+ if (tail.length === 0)
6672
+ return this;
6673
+ if (tail.length > 1) {
6674
+ let list = this;
6675
+ for (let item of tail)
6676
+ list = list.concat(item);
6677
+ return list;
6678
+ }
6679
+ return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
6680
+ }
6681
+ filter(check, context) {
6682
+ const filtered = new $mol_range2_array();
6683
+ for (let index = 0; index < this.length; ++index) {
6684
+ const item = this[index];
6685
+ if (check.call(context, item, index, this))
6686
+ filtered.push(item);
6687
+ }
6688
+ return filtered;
6689
+ }
6690
+ forEach(proceed, context) {
6691
+ for (let [key, value] of this.entries())
6692
+ proceed.call(context, value, key, this);
6693
+ }
6694
+ map(proceed, context) {
6695
+ return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
6696
+ }
6697
+ reduce(merge, result) {
6698
+ let index = 0;
6699
+ if (arguments.length === 1) {
6700
+ result = this[index++];
6701
+ }
6702
+ for (; index < this.length; ++index) {
6703
+ result = merge(result, this[index], index, this);
6704
+ }
6705
+ return result;
6706
+ }
6707
+ toReversed() {
6708
+ return $mol_range2(index => this[this.length - 1 - index], () => this.length);
6709
+ }
6710
+ slice(from = 0, to = this.length) {
6711
+ return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
6712
+ }
6713
+ some(check, context) {
6714
+ for (let index = 0; index < this.length; ++index) {
6715
+ if (check.call(context, this[index], index, this))
6716
+ return true;
6717
+ }
6718
+ return false;
6719
+ }
6720
+ every(check, context) {
6721
+ for (let index = 0; index < this.length; ++index) {
6722
+ if (!check.call(context, this[index], index, this))
6723
+ return false;
6724
+ }
6725
+ return true;
6726
+ }
6727
+ reverse() {
6728
+ return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
6729
+ }
6730
+ sort() {
6731
+ return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
6732
+ }
6733
+ [Symbol.toPrimitive]() {
6734
+ return $mol_guid();
6735
+ }
6736
+ }
6737
+ $.$mol_range2_array = $mol_range2_array;
6738
+ })($ || ($ = {}));
6739
+ //mol/range2/range2.ts
6740
+ ;
6741
+ "use strict";
6742
+ var $;
6743
+ (function ($) {
6744
+ $mol_test({
6745
+ 'lazy calls'() {
6746
+ let calls = 0;
6747
+ const list = $mol_range2(index => (++calls, index), () => 10);
6748
+ $mol_assert_ok(list instanceof Array);
6749
+ $mol_assert_equal(list.length, 10);
6750
+ $mol_assert_equal(list[-1], undefined);
6751
+ $mol_assert_equal(list[0], 0);
6752
+ $mol_assert_equal(list[9], 9);
6753
+ $mol_assert_equal(list[9.5], undefined);
6754
+ $mol_assert_equal(list[10], undefined);
6755
+ $mol_assert_equal(calls, 2);
6756
+ },
6757
+ 'infinity list'() {
6758
+ let calls = 0;
6759
+ const list = $mol_range2(index => (++calls, index));
6760
+ $mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
6761
+ $mol_assert_equal(list[0], 0);
6762
+ $mol_assert_equal(list[4], 4);
6763
+ $mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
6764
+ $mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
6765
+ $mol_assert_equal(calls, 3);
6766
+ },
6767
+ 'stringify'() {
6768
+ const list = $mol_range2(i => i, () => 5);
6769
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
6770
+ $mol_assert_equal(list.join(';'), '0;1;2;3;4');
6771
+ },
6772
+ 'for-of'() {
6773
+ let log = '';
6774
+ for (let i of $mol_range2(i => i + 1, () => 5)) {
6775
+ log += i;
6776
+ }
6777
+ $mol_assert_equal(log, '12345');
6778
+ },
6779
+ 'for-in'() {
6780
+ let log = '';
6781
+ for (let i in $mol_range2(i => i, () => 5)) {
6782
+ log += i;
6783
+ }
6784
+ $mol_assert_equal(log, '01234');
6785
+ },
6786
+ 'forEach'() {
6787
+ let log = '';
6788
+ $mol_range2(i => i, () => 5).forEach(i => log += i);
6789
+ $mol_assert_equal(log, '01234');
6790
+ },
6791
+ 'lazy concat'() {
6792
+ let calls1 = 0;
6793
+ let calls2 = 0;
6794
+ const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
6795
+ $mol_assert_ok(list instanceof Array);
6796
+ $mol_assert_equal(list.length, 15);
6797
+ $mol_assert_equal(list[0], 0);
6798
+ $mol_assert_equal(list[4], 4);
6799
+ $mol_assert_equal(list[5], 0);
6800
+ $mol_assert_equal(list[9], 4);
6801
+ $mol_assert_equal(list[10], 0);
6802
+ $mol_assert_equal(list[14], 4);
6803
+ $mol_assert_equal(list[15], undefined);
6804
+ $mol_assert_equal(calls1, 2);
6805
+ $mol_assert_equal(calls2, 2);
6806
+ },
6807
+ 'filter'() {
6808
+ let calls = 0;
6809
+ const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
6810
+ $mol_assert_ok(list instanceof Array);
6811
+ $mol_assert_equal(list.length, 3);
6812
+ $mol_assert_equal(list[0], 1);
6813
+ $mol_assert_equal(list[2], 5);
6814
+ $mol_assert_equal(list[3], undefined);
6815
+ $mol_assert_equal(calls, 10);
6816
+ },
6817
+ 'reverse'() {
6818
+ let calls = 0;
6819
+ const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
6820
+ $mol_assert_ok(list instanceof Array);
6821
+ $mol_assert_equal(list.length, 3);
6822
+ $mol_assert_equal(list[0], 9);
6823
+ $mol_assert_equal(list[2], 7);
6824
+ $mol_assert_equal(list[3], undefined);
6825
+ $mol_assert_equal(calls, 2);
6826
+ },
6827
+ 'reduce'() {
6828
+ let calls = 0;
6829
+ const list = $mol_range2().slice(1, 6);
6830
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
6831
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
6832
+ },
6833
+ 'lazy map'() {
6834
+ let calls1 = 0;
6835
+ let calls2 = 0;
6836
+ const source = $mol_range2(index => (++calls1, index), () => 5);
6837
+ const target = source.map((item, index, self) => {
6838
+ ++calls2;
6839
+ $mol_assert_equal(source, self);
6840
+ return index + 10;
6841
+ }, () => 5);
6842
+ $mol_assert_ok(target instanceof Array);
6843
+ $mol_assert_equal(target.length, 5);
6844
+ $mol_assert_equal(target[0], 10);
6845
+ $mol_assert_equal(target[4], 14);
6846
+ $mol_assert_equal(target[5], undefined);
6847
+ $mol_assert_equal(calls1, 2);
6848
+ $mol_assert_equal(calls2, 2);
6849
+ },
6850
+ 'lazy slice'() {
6851
+ let calls = 0;
6852
+ const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
6853
+ $mol_assert_ok(list instanceof Array);
6854
+ $mol_assert_equal(list.length, 4);
6855
+ $mol_assert_equal(list[0], 3);
6856
+ $mol_assert_equal(list[3], 6);
6857
+ $mol_assert_equal(list[4], undefined);
6858
+ $mol_assert_equal(calls, 2);
6859
+ },
6860
+ 'lazy some'() {
6861
+ let calls = 0;
6862
+ $mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
6863
+ $mol_assert_equal(calls, 3);
6864
+ $mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
6865
+ $mol_assert_ok($mol_range2(i => i).some(v => v > 5));
6866
+ },
6867
+ 'lazy every'() {
6868
+ let calls = 0;
6869
+ $mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
6870
+ $mol_assert_equal(calls, 3);
6871
+ $mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
6872
+ $mol_assert_not($mol_range2(i => i).every(v => v < 5));
6873
+ },
6874
+ 'lazyfy'() {
6875
+ let calls = 0;
6876
+ const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
6877
+ $mol_assert_ok(list instanceof Array);
6878
+ $mol_assert_equal(list.length, 4);
6879
+ $mol_assert_equal(calls, 0);
6880
+ $mol_assert_equal(list[0], 12);
6881
+ $mol_assert_equal(list[3], 15);
6882
+ $mol_assert_equal(list[4], undefined);
6883
+ $mol_assert_equal(calls, 2);
6884
+ },
6885
+ 'prevent modification'() {
6886
+ const list = $mol_range2(i => i, () => 5);
6887
+ $mol_assert_fail(() => list.push(4), TypeError);
6888
+ $mol_assert_fail(() => list.pop(), TypeError);
6889
+ $mol_assert_fail(() => list.unshift(4), TypeError);
6890
+ $mol_assert_fail(() => list.shift(), TypeError);
6891
+ $mol_assert_fail(() => list.splice(1, 2), TypeError);
6892
+ $mol_assert_fail(() => list[1] = 2, TypeError);
6893
+ $mol_assert_fail(() => list.reverse(), TypeError);
6894
+ $mol_assert_fail(() => list.sort(), TypeError);
6895
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
6896
+ }
6897
+ });
6898
+ })($ || ($ = {}));
6899
+ //mol/range2/range2.test.ts
6900
+ ;
6901
+ "use strict";
6902
+ var $;
6626
6903
  (function ($) {
6627
6904
  $mol_test({
6628
6905
  'nulls & undefineds'() {
@@ -6652,6 +6929,8 @@ var $;
6652
6929
  $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
6653
6930
  $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
6654
6931
  $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
6932
+ $mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
6933
+ $mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
6655
6934
  },
6656
6935
  'Non POJO are different'() {
6657
6936
  class Thing extends Object {