hyoo_sync_client 0.0.178 → 0.0.180

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
@@ -2066,6 +2066,8 @@ var $;
2066
2066
  result = compare_pojo(left, right);
2067
2067
  else if (!Reflect.getPrototypeOf(left_proto))
2068
2068
  result = compare_pojo(left, right);
2069
+ else if (Symbol.toPrimitive in left)
2070
+ result = compare_primitive(left, right);
2069
2071
  else if (Array.isArray(left))
2070
2072
  result = compare_array(left, right);
2071
2073
  else if (left instanceof Set)
@@ -2076,8 +2078,6 @@ var $;
2076
2078
  result = compare_buffer(left, right);
2077
2079
  else if (Symbol.iterator in left)
2078
2080
  result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
2079
- else if (Symbol.toPrimitive in left)
2080
- result = compare_primitive(left, right);
2081
2081
  else
2082
2082
  result = false;
2083
2083
  }
package/node.test.js CHANGED
@@ -2058,6 +2058,8 @@ var $;
2058
2058
  result = compare_pojo(left, right);
2059
2059
  else if (!Reflect.getPrototypeOf(left_proto))
2060
2060
  result = compare_pojo(left, right);
2061
+ else if (Symbol.toPrimitive in left)
2062
+ result = compare_primitive(left, right);
2061
2063
  else if (Array.isArray(left))
2062
2064
  result = compare_array(left, right);
2063
2065
  else if (left instanceof Set)
@@ -2068,8 +2070,6 @@ var $;
2068
2070
  result = compare_buffer(left, right);
2069
2071
  else if (Symbol.iterator in left)
2070
2072
  result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
2071
- else if (Symbol.toPrimitive in left)
2072
- result = compare_primitive(left, right);
2073
2073
  else
2074
2074
  result = false;
2075
2075
  }
@@ -4843,6 +4843,283 @@ var $;
4843
4843
  ;
4844
4844
  "use strict";
4845
4845
  var $;
4846
+ (function ($) {
4847
+ function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
4848
+ return new Proxy(new $mol_range2_array(), {
4849
+ get(target, field) {
4850
+ if (typeof field === 'string') {
4851
+ if (field === 'length')
4852
+ return size();
4853
+ const index = Number(field);
4854
+ if (index < 0)
4855
+ return undefined;
4856
+ if (index >= size())
4857
+ return undefined;
4858
+ if (index === Math.trunc(index))
4859
+ return item(index);
4860
+ }
4861
+ return target[field];
4862
+ },
4863
+ set(target, field) {
4864
+ return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
4865
+ },
4866
+ ownKeys(target) {
4867
+ return [...Array(size())].map((v, i) => String(i)).concat('length');
4868
+ },
4869
+ getOwnPropertyDescriptor(target, field) {
4870
+ if (field === "length")
4871
+ return {
4872
+ value: size(),
4873
+ writable: true,
4874
+ enumerable: false,
4875
+ configurable: false,
4876
+ };
4877
+ const index = Number(field);
4878
+ if (index === Math.trunc(index))
4879
+ return {
4880
+ get: () => this.get(target, field, this),
4881
+ enumerable: true,
4882
+ configurable: true,
4883
+ };
4884
+ return Object.getOwnPropertyDescriptor(target, field);
4885
+ }
4886
+ });
4887
+ }
4888
+ $.$mol_range2 = $mol_range2;
4889
+ class $mol_range2_array extends Array {
4890
+ concat(...tail) {
4891
+ if (tail.length === 0)
4892
+ return this;
4893
+ if (tail.length > 1) {
4894
+ let list = this;
4895
+ for (let item of tail)
4896
+ list = list.concat(item);
4897
+ return list;
4898
+ }
4899
+ return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
4900
+ }
4901
+ filter(check, context) {
4902
+ const filtered = new $mol_range2_array();
4903
+ for (let index = 0; index < this.length; ++index) {
4904
+ const item = this[index];
4905
+ if (check.call(context, item, index, this))
4906
+ filtered.push(item);
4907
+ }
4908
+ return filtered;
4909
+ }
4910
+ forEach(proceed, context) {
4911
+ for (let [key, value] of this.entries())
4912
+ proceed.call(context, value, key, this);
4913
+ }
4914
+ map(proceed, context) {
4915
+ return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
4916
+ }
4917
+ reduce(merge, result) {
4918
+ let index = 0;
4919
+ if (arguments.length === 1) {
4920
+ result = this[index++];
4921
+ }
4922
+ for (; index < this.length; ++index) {
4923
+ result = merge(result, this[index], index, this);
4924
+ }
4925
+ return result;
4926
+ }
4927
+ toReversed() {
4928
+ return $mol_range2(index => this[this.length - 1 - index], () => this.length);
4929
+ }
4930
+ slice(from = 0, to = this.length) {
4931
+ return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
4932
+ }
4933
+ some(check, context) {
4934
+ for (let index = 0; index < this.length; ++index) {
4935
+ if (check.call(context, this[index], index, this))
4936
+ return true;
4937
+ }
4938
+ return false;
4939
+ }
4940
+ every(check, context) {
4941
+ for (let index = 0; index < this.length; ++index) {
4942
+ if (!check.call(context, this[index], index, this))
4943
+ return false;
4944
+ }
4945
+ return true;
4946
+ }
4947
+ reverse() {
4948
+ return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
4949
+ }
4950
+ sort() {
4951
+ return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
4952
+ }
4953
+ [Symbol.toPrimitive]() {
4954
+ return $mol_guid();
4955
+ }
4956
+ }
4957
+ $.$mol_range2_array = $mol_range2_array;
4958
+ })($ || ($ = {}));
4959
+ //mol/range2/range2.ts
4960
+ ;
4961
+ "use strict";
4962
+ var $;
4963
+ (function ($) {
4964
+ $mol_test({
4965
+ 'lazy calls'() {
4966
+ let calls = 0;
4967
+ const list = $mol_range2(index => (++calls, index), () => 10);
4968
+ $mol_assert_ok(list instanceof Array);
4969
+ $mol_assert_equal(list.length, 10);
4970
+ $mol_assert_equal(list[-1], undefined);
4971
+ $mol_assert_equal(list[0], 0);
4972
+ $mol_assert_equal(list[9], 9);
4973
+ $mol_assert_equal(list[9.5], undefined);
4974
+ $mol_assert_equal(list[10], undefined);
4975
+ $mol_assert_equal(calls, 2);
4976
+ },
4977
+ 'infinity list'() {
4978
+ let calls = 0;
4979
+ const list = $mol_range2(index => (++calls, index));
4980
+ $mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
4981
+ $mol_assert_equal(list[0], 0);
4982
+ $mol_assert_equal(list[4], 4);
4983
+ $mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
4984
+ $mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
4985
+ $mol_assert_equal(calls, 3);
4986
+ },
4987
+ 'stringify'() {
4988
+ const list = $mol_range2(i => i, () => 5);
4989
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
4990
+ $mol_assert_equal(list.join(';'), '0;1;2;3;4');
4991
+ },
4992
+ 'for-of'() {
4993
+ let log = '';
4994
+ for (let i of $mol_range2(i => i + 1, () => 5)) {
4995
+ log += i;
4996
+ }
4997
+ $mol_assert_equal(log, '12345');
4998
+ },
4999
+ 'for-in'() {
5000
+ let log = '';
5001
+ for (let i in $mol_range2(i => i, () => 5)) {
5002
+ log += i;
5003
+ }
5004
+ $mol_assert_equal(log, '01234');
5005
+ },
5006
+ 'forEach'() {
5007
+ let log = '';
5008
+ $mol_range2(i => i, () => 5).forEach(i => log += i);
5009
+ $mol_assert_equal(log, '01234');
5010
+ },
5011
+ 'lazy concat'() {
5012
+ let calls1 = 0;
5013
+ let calls2 = 0;
5014
+ const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
5015
+ $mol_assert_ok(list instanceof Array);
5016
+ $mol_assert_equal(list.length, 15);
5017
+ $mol_assert_equal(list[0], 0);
5018
+ $mol_assert_equal(list[4], 4);
5019
+ $mol_assert_equal(list[5], 0);
5020
+ $mol_assert_equal(list[9], 4);
5021
+ $mol_assert_equal(list[10], 0);
5022
+ $mol_assert_equal(list[14], 4);
5023
+ $mol_assert_equal(list[15], undefined);
5024
+ $mol_assert_equal(calls1, 2);
5025
+ $mol_assert_equal(calls2, 2);
5026
+ },
5027
+ 'filter'() {
5028
+ let calls = 0;
5029
+ const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
5030
+ $mol_assert_ok(list instanceof Array);
5031
+ $mol_assert_equal(list.length, 3);
5032
+ $mol_assert_equal(list[0], 1);
5033
+ $mol_assert_equal(list[2], 5);
5034
+ $mol_assert_equal(list[3], undefined);
5035
+ $mol_assert_equal(calls, 10);
5036
+ },
5037
+ 'reverse'() {
5038
+ let calls = 0;
5039
+ const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
5040
+ $mol_assert_ok(list instanceof Array);
5041
+ $mol_assert_equal(list.length, 3);
5042
+ $mol_assert_equal(list[0], 9);
5043
+ $mol_assert_equal(list[2], 7);
5044
+ $mol_assert_equal(list[3], undefined);
5045
+ $mol_assert_equal(calls, 2);
5046
+ },
5047
+ 'reduce'() {
5048
+ let calls = 0;
5049
+ const list = $mol_range2().slice(1, 6);
5050
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
5051
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
5052
+ },
5053
+ 'lazy map'() {
5054
+ let calls1 = 0;
5055
+ let calls2 = 0;
5056
+ const source = $mol_range2(index => (++calls1, index), () => 5);
5057
+ const target = source.map((item, index, self) => {
5058
+ ++calls2;
5059
+ $mol_assert_equal(source, self);
5060
+ return index + 10;
5061
+ }, () => 5);
5062
+ $mol_assert_ok(target instanceof Array);
5063
+ $mol_assert_equal(target.length, 5);
5064
+ $mol_assert_equal(target[0], 10);
5065
+ $mol_assert_equal(target[4], 14);
5066
+ $mol_assert_equal(target[5], undefined);
5067
+ $mol_assert_equal(calls1, 2);
5068
+ $mol_assert_equal(calls2, 2);
5069
+ },
5070
+ 'lazy slice'() {
5071
+ let calls = 0;
5072
+ const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
5073
+ $mol_assert_ok(list instanceof Array);
5074
+ $mol_assert_equal(list.length, 4);
5075
+ $mol_assert_equal(list[0], 3);
5076
+ $mol_assert_equal(list[3], 6);
5077
+ $mol_assert_equal(list[4], undefined);
5078
+ $mol_assert_equal(calls, 2);
5079
+ },
5080
+ 'lazy some'() {
5081
+ let calls = 0;
5082
+ $mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
5083
+ $mol_assert_equal(calls, 3);
5084
+ $mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
5085
+ $mol_assert_ok($mol_range2(i => i).some(v => v > 5));
5086
+ },
5087
+ 'lazy every'() {
5088
+ let calls = 0;
5089
+ $mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
5090
+ $mol_assert_equal(calls, 3);
5091
+ $mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
5092
+ $mol_assert_not($mol_range2(i => i).every(v => v < 5));
5093
+ },
5094
+ 'lazyfy'() {
5095
+ let calls = 0;
5096
+ const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
5097
+ $mol_assert_ok(list instanceof Array);
5098
+ $mol_assert_equal(list.length, 4);
5099
+ $mol_assert_equal(calls, 0);
5100
+ $mol_assert_equal(list[0], 12);
5101
+ $mol_assert_equal(list[3], 15);
5102
+ $mol_assert_equal(list[4], undefined);
5103
+ $mol_assert_equal(calls, 2);
5104
+ },
5105
+ 'prevent modification'() {
5106
+ const list = $mol_range2(i => i, () => 5);
5107
+ $mol_assert_fail(() => list.push(4), TypeError);
5108
+ $mol_assert_fail(() => list.pop(), TypeError);
5109
+ $mol_assert_fail(() => list.unshift(4), TypeError);
5110
+ $mol_assert_fail(() => list.shift(), TypeError);
5111
+ $mol_assert_fail(() => list.splice(1, 2), TypeError);
5112
+ $mol_assert_fail(() => list[1] = 2, TypeError);
5113
+ $mol_assert_fail(() => list.reverse(), TypeError);
5114
+ $mol_assert_fail(() => list.sort(), TypeError);
5115
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
5116
+ }
5117
+ });
5118
+ })($ || ($ = {}));
5119
+ //mol/range2/range2.test.ts
5120
+ ;
5121
+ "use strict";
5122
+ var $;
4846
5123
  (function ($) {
4847
5124
  $mol_test({
4848
5125
  'nulls & undefineds'() {
@@ -4872,6 +5149,8 @@ var $;
4872
5149
  $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
4873
5150
  $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
4874
5151
  $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
5152
+ $mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
5153
+ $mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
4875
5154
  },
4876
5155
  'Non POJO are different'() {
4877
5156
  class Thing extends Object {