mol_plot_all 1.2.879 → 1.2.881

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 CHANGED
@@ -6692,7 +6692,12 @@ var $;
6692
6692
  var $;
6693
6693
  (function ($) {
6694
6694
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
6695
- return new Proxy(new $mol_range2_array(), {
6695
+ const source = typeof item === 'function' ? new $mol_range2_array() : item;
6696
+ if (typeof item !== 'function') {
6697
+ item = index => source[index];
6698
+ size = () => source.length;
6699
+ }
6700
+ return new Proxy(source, {
6696
6701
  get(target, field) {
6697
6702
  if (typeof field === 'string') {
6698
6703
  if (field === 'length')
@@ -6705,7 +6710,7 @@ var $;
6705
6710
  if (index === Math.trunc(index))
6706
6711
  return item(index);
6707
6712
  }
6708
- return target[field];
6713
+ return $mol_range2_array.prototype[field];
6709
6714
  },
6710
6715
  set(target, field) {
6711
6716
  return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
@@ -6746,13 +6751,16 @@ var $;
6746
6751
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
6747
6752
  }
6748
6753
  filter(check, context) {
6749
- const filtered = new $mol_range2_array();
6750
- for (let index = 0; index < this.length; ++index) {
6751
- const item = this[index];
6752
- if (check.call(context, item, index, this))
6753
- filtered.push(item);
6754
- }
6755
- return filtered;
6754
+ const filtered = [];
6755
+ let cursor = -1;
6756
+ return $mol_range2(index => {
6757
+ while (cursor < this.length && index >= filtered.length - 1) {
6758
+ const val = this[++cursor];
6759
+ if (check(val, cursor, this))
6760
+ filtered.push(val);
6761
+ }
6762
+ return filtered[index];
6763
+ }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
6756
6764
  }
6757
6765
  forEach(proceed, context) {
6758
6766
  for (let [key, value] of this.entries())
@@ -6812,7 +6820,7 @@ var $;
6812
6820
  'lazy calls'() {
6813
6821
  let calls = 0;
6814
6822
  const list = $mol_range2(index => (++calls, index), () => 10);
6815
- $mol_assert_ok(list instanceof Array);
6823
+ $mol_assert_equal(true, list instanceof Array);
6816
6824
  $mol_assert_equal(list.length, 10);
6817
6825
  $mol_assert_equal(list[-1], undefined);
6818
6826
  $mol_assert_equal(list[0], 0);
@@ -6855,11 +6863,17 @@ var $;
6855
6863
  $mol_range2(i => i, () => 5).forEach(i => log += i);
6856
6864
  $mol_assert_equal(log, '01234');
6857
6865
  },
6866
+ 'reduce'() {
6867
+ let calls = 0;
6868
+ const list = $mol_range2().slice(1, 6);
6869
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
6870
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
6871
+ },
6858
6872
  'lazy concat'() {
6859
6873
  let calls1 = 0;
6860
6874
  let calls2 = 0;
6861
6875
  const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
6862
- $mol_assert_ok(list instanceof Array);
6876
+ $mol_assert_equal(true, list instanceof Array);
6863
6877
  $mol_assert_equal(list.length, 15);
6864
6878
  $mol_assert_equal(list[0], 0);
6865
6879
  $mol_assert_equal(list[4], 4);
@@ -6871,32 +6885,26 @@ var $;
6871
6885
  $mol_assert_equal(calls1, 2);
6872
6886
  $mol_assert_equal(calls2, 2);
6873
6887
  },
6874
- 'filter'() {
6888
+ 'lazy filter'() {
6875
6889
  let calls = 0;
6876
- const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
6877
- $mol_assert_ok(list instanceof Array);
6890
+ const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
6891
+ $mol_assert_equal(true, list instanceof Array);
6878
6892
  $mol_assert_equal(list.length, 3);
6879
6893
  $mol_assert_equal(list[0], 1);
6880
6894
  $mol_assert_equal(list[2], 5);
6881
6895
  $mol_assert_equal(list[3], undefined);
6882
- $mol_assert_equal(calls, 10);
6896
+ $mol_assert_equal(calls, 8);
6883
6897
  },
6884
- 'reverse'() {
6898
+ 'lazy reverse'() {
6885
6899
  let calls = 0;
6886
6900
  const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
6887
- $mol_assert_ok(list instanceof Array);
6901
+ $mol_assert_equal(true, list instanceof Array);
6888
6902
  $mol_assert_equal(list.length, 3);
6889
6903
  $mol_assert_equal(list[0], 9);
6890
6904
  $mol_assert_equal(list[2], 7);
6891
6905
  $mol_assert_equal(list[3], undefined);
6892
6906
  $mol_assert_equal(calls, 2);
6893
6907
  },
6894
- 'reduce'() {
6895
- let calls = 0;
6896
- const list = $mol_range2().slice(1, 6);
6897
- $mol_assert_equal(list.reduce((s, v) => s + v), 15);
6898
- $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
6899
- },
6900
6908
  'lazy map'() {
6901
6909
  let calls1 = 0;
6902
6910
  let calls2 = 0;
@@ -6906,7 +6914,7 @@ var $;
6906
6914
  $mol_assert_equal(source, self);
6907
6915
  return index + 10;
6908
6916
  }, () => 5);
6909
- $mol_assert_ok(target instanceof Array);
6917
+ $mol_assert_equal(true, target instanceof Array);
6910
6918
  $mol_assert_equal(target.length, 5);
6911
6919
  $mol_assert_equal(target[0], 10);
6912
6920
  $mol_assert_equal(target[4], 14);
@@ -6917,7 +6925,7 @@ var $;
6917
6925
  'lazy slice'() {
6918
6926
  let calls = 0;
6919
6927
  const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
6920
- $mol_assert_ok(list instanceof Array);
6928
+ $mol_assert_equal(true, list instanceof Array);
6921
6929
  $mol_assert_equal(list.length, 4);
6922
6930
  $mol_assert_equal(list[0], 3);
6923
6931
  $mol_assert_equal(list[3], 6);
@@ -6926,22 +6934,22 @@ var $;
6926
6934
  },
6927
6935
  'lazy some'() {
6928
6936
  let calls = 0;
6929
- $mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
6937
+ $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
6930
6938
  $mol_assert_equal(calls, 3);
6931
- $mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
6932
- $mol_assert_ok($mol_range2(i => i).some(v => v > 5));
6939
+ $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
6940
+ $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
6933
6941
  },
6934
6942
  'lazy every'() {
6935
6943
  let calls = 0;
6936
- $mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
6944
+ $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
6937
6945
  $mol_assert_equal(calls, 3);
6938
- $mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
6939
- $mol_assert_not($mol_range2(i => i).every(v => v < 5));
6946
+ $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
6947
+ $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
6940
6948
  },
6941
6949
  'lazyfy'() {
6942
6950
  let calls = 0;
6943
- const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
6944
- $mol_assert_ok(list instanceof Array);
6951
+ const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
6952
+ $mol_assert_equal(true, list instanceof Array);
6945
6953
  $mol_assert_equal(list.length, 4);
6946
6954
  $mol_assert_equal(calls, 0);
6947
6955
  $mol_assert_equal(list[0], 12);