mol_text_distance 0.0.661 → 0.0.663

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 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/text/profile/profile.ts","mol/text/profile/distance/distance.ts","mol/text/distance/readme.md","mol/text/distance/distance.ts"],"mods":{},"deps_in":{"mol/text":{"mol/text/distance":-9007199254740991,"mol/text/profile":-9007199254740991},"mol":{"mol/text":-9007199254740991},"":{"mol":-9007199254740991},"mol/text/profile/distance":{"mol/text/distance":-2},"mol/text/profile":{"mol/text/profile/distance":-9007199254740991,"mol/text/distance":-3}},"deps_out":{"mol/text/distance":{"mol/text":-9007199254740991,"mol/text/profile/distance":-2,"mol/text/profile":-3},"mol/text":{"mol":-9007199254740991},"mol":{"":-9007199254740991},"mol/text/profile/distance":{"mol/text/profile":-9007199254740991},"mol/text/profile":{"mol/text":-9007199254740991}},"sloc":{"ts":55,"LICENSE":113,"md":503,"lock":974,"js":9,"json":92,"tree":41,"CNAME":1,"html":1},"deps":{"mol/text/distance":{"..":-9007199254740991,"/mol/text/distance":-1,"/mol/text/profile/distance":-2,"/mol/text/profile":-3},"mol/text":{"..":-9007199254740991},"mol":{"..":-9007199254740991},"":{},"mol/text/profile/distance":{"..":-9007199254740991,"/mol/text/profile/distance":-1},"mol/text/profile":{"..":-9007199254740991,"/mol/text/profile":-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/text/profile/profile.ts","mol/text/profile/distance/distance.ts","mol/text/distance/readme.md","mol/text/distance/distance.ts"],"mods":{},"deps_in":{"mol/text":{"mol/text/distance":-9007199254740991,"mol/text/profile":-9007199254740991},"mol":{"mol/text":-9007199254740991},"":{"mol":-9007199254740991},"mol/text/profile/distance":{"mol/text/distance":-2},"mol/text/profile":{"mol/text/profile/distance":-9007199254740991,"mol/text/distance":-3}},"deps_out":{"mol/text/distance":{"mol/text":-9007199254740991,"mol/text/profile/distance":-2,"mol/text/profile":-3},"mol/text":{"mol":-9007199254740991},"mol":{"":-9007199254740991},"mol/text/profile/distance":{"mol/text/profile":-9007199254740991},"mol/text/profile":{"mol/text":-9007199254740991}},"sloc":{"ts":55,"LICENSE":113,"md":503,"lock":974,"js":9,"json":93,"tree":41,"CNAME":1,"html":1},"deps":{"mol/text/distance":{"..":-9007199254740991,"/mol/text/distance":-1,"/mol/text/profile/distance":-2,"/mol/text/profile":-3},"mol/text":{"..":-9007199254740991},"mol":{"..":-9007199254740991},"":{},"mol/text/profile/distance":{"..":-9007199254740991,"/mol/text/profile/distance":-1},"mol/text/profile":{"..":-9007199254740991,"/mol/text/profile":-1}}}
package/node.test.js CHANGED
@@ -710,7 +710,12 @@ var $;
710
710
  var $;
711
711
  (function ($) {
712
712
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
713
- return new Proxy(new $mol_range2_array(), {
713
+ const source = typeof item === 'function' ? new $mol_range2_array() : item;
714
+ if (typeof item !== 'function') {
715
+ item = index => source[index];
716
+ size = () => source.length;
717
+ }
718
+ return new Proxy(source, {
714
719
  get(target, field) {
715
720
  if (typeof field === 'string') {
716
721
  if (field === 'length')
@@ -723,7 +728,7 @@ var $;
723
728
  if (index === Math.trunc(index))
724
729
  return item(index);
725
730
  }
726
- return target[field];
731
+ return $mol_range2_array.prototype[field];
727
732
  },
728
733
  set(target, field) {
729
734
  return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
@@ -764,13 +769,16 @@ var $;
764
769
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
765
770
  }
766
771
  filter(check, context) {
767
- const filtered = new $mol_range2_array();
768
- for (let index = 0; index < this.length; ++index) {
769
- const item = this[index];
770
- if (check.call(context, item, index, this))
771
- filtered.push(item);
772
- }
773
- return filtered;
772
+ const filtered = [];
773
+ let cursor = -1;
774
+ return $mol_range2(index => {
775
+ while (cursor < this.length && index >= filtered.length - 1) {
776
+ const val = this[++cursor];
777
+ if (check(val, cursor, this))
778
+ filtered.push(val);
779
+ }
780
+ return filtered[index];
781
+ }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
774
782
  }
775
783
  forEach(proceed, context) {
776
784
  for (let [key, value] of this.entries())
@@ -830,7 +838,7 @@ var $;
830
838
  'lazy calls'() {
831
839
  let calls = 0;
832
840
  const list = $mol_range2(index => (++calls, index), () => 10);
833
- $mol_assert_ok(list instanceof Array);
841
+ $mol_assert_equal(true, list instanceof Array);
834
842
  $mol_assert_equal(list.length, 10);
835
843
  $mol_assert_equal(list[-1], undefined);
836
844
  $mol_assert_equal(list[0], 0);
@@ -873,11 +881,17 @@ var $;
873
881
  $mol_range2(i => i, () => 5).forEach(i => log += i);
874
882
  $mol_assert_equal(log, '01234');
875
883
  },
884
+ 'reduce'() {
885
+ let calls = 0;
886
+ const list = $mol_range2().slice(1, 6);
887
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
888
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
889
+ },
876
890
  'lazy concat'() {
877
891
  let calls1 = 0;
878
892
  let calls2 = 0;
879
893
  const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
880
- $mol_assert_ok(list instanceof Array);
894
+ $mol_assert_equal(true, list instanceof Array);
881
895
  $mol_assert_equal(list.length, 15);
882
896
  $mol_assert_equal(list[0], 0);
883
897
  $mol_assert_equal(list[4], 4);
@@ -889,32 +903,26 @@ var $;
889
903
  $mol_assert_equal(calls1, 2);
890
904
  $mol_assert_equal(calls2, 2);
891
905
  },
892
- 'filter'() {
906
+ 'lazy filter'() {
893
907
  let calls = 0;
894
- const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
895
- $mol_assert_ok(list instanceof Array);
908
+ const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
909
+ $mol_assert_equal(true, list instanceof Array);
896
910
  $mol_assert_equal(list.length, 3);
897
911
  $mol_assert_equal(list[0], 1);
898
912
  $mol_assert_equal(list[2], 5);
899
913
  $mol_assert_equal(list[3], undefined);
900
- $mol_assert_equal(calls, 10);
914
+ $mol_assert_equal(calls, 8);
901
915
  },
902
- 'reverse'() {
916
+ 'lazy reverse'() {
903
917
  let calls = 0;
904
918
  const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
905
- $mol_assert_ok(list instanceof Array);
919
+ $mol_assert_equal(true, list instanceof Array);
906
920
  $mol_assert_equal(list.length, 3);
907
921
  $mol_assert_equal(list[0], 9);
908
922
  $mol_assert_equal(list[2], 7);
909
923
  $mol_assert_equal(list[3], undefined);
910
924
  $mol_assert_equal(calls, 2);
911
925
  },
912
- 'reduce'() {
913
- let calls = 0;
914
- const list = $mol_range2().slice(1, 6);
915
- $mol_assert_equal(list.reduce((s, v) => s + v), 15);
916
- $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
917
- },
918
926
  'lazy map'() {
919
927
  let calls1 = 0;
920
928
  let calls2 = 0;
@@ -924,7 +932,7 @@ var $;
924
932
  $mol_assert_equal(source, self);
925
933
  return index + 10;
926
934
  }, () => 5);
927
- $mol_assert_ok(target instanceof Array);
935
+ $mol_assert_equal(true, target instanceof Array);
928
936
  $mol_assert_equal(target.length, 5);
929
937
  $mol_assert_equal(target[0], 10);
930
938
  $mol_assert_equal(target[4], 14);
@@ -935,7 +943,7 @@ var $;
935
943
  'lazy slice'() {
936
944
  let calls = 0;
937
945
  const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
938
- $mol_assert_ok(list instanceof Array);
946
+ $mol_assert_equal(true, list instanceof Array);
939
947
  $mol_assert_equal(list.length, 4);
940
948
  $mol_assert_equal(list[0], 3);
941
949
  $mol_assert_equal(list[3], 6);
@@ -944,22 +952,22 @@ var $;
944
952
  },
945
953
  'lazy some'() {
946
954
  let calls = 0;
947
- $mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
955
+ $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
948
956
  $mol_assert_equal(calls, 3);
949
- $mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
950
- $mol_assert_ok($mol_range2(i => i).some(v => v > 5));
957
+ $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
958
+ $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
951
959
  },
952
960
  'lazy every'() {
953
961
  let calls = 0;
954
- $mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
962
+ $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
955
963
  $mol_assert_equal(calls, 3);
956
- $mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
957
- $mol_assert_not($mol_range2(i => i).every(v => v < 5));
964
+ $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
965
+ $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
958
966
  },
959
967
  'lazyfy'() {
960
968
  let calls = 0;
961
- const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
962
- $mol_assert_ok(list instanceof Array);
969
+ const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
970
+ $mol_assert_equal(true, list instanceof Array);
963
971
  $mol_assert_equal(list.length, 4);
964
972
  $mol_assert_equal(calls, 0);
965
973
  $mol_assert_equal(list[0], 12);