@byloth/core 1.5.0-rc.6 → 1.5.0-rc.8

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/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
- var k = Object.defineProperty;
2
- var S = (o, e, t) => e in o ? k(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var u = (o, e, t) => S(o, typeof e != "symbol" ? e + "" : e, t);
1
+ var S = Object.defineProperty;
2
+ var b = (o, e, t) => e in o ? S(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var u = (o, e, t) => b(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  class a {
5
5
  constructor(e) {
6
6
  u(this, "_iterator");
@@ -114,12 +114,45 @@ class a {
114
114
  return this;
115
115
  }
116
116
  }
117
- class f {
117
+ class h {
118
118
  constructor(e) {
119
119
  u(this, "_iterator");
120
120
  u(this, "return");
121
121
  u(this, "throw");
122
- e instanceof Function ? this._iterator = e() : Symbol.asyncIterator in e ? this._iterator = e[Symbol.asyncIterator]() : this._iterator = e, this._iterator.return && (this.return = (t) => this._iterator.return(t)), this._iterator.throw && (this.throw = (t) => this._iterator.throw(t));
122
+ if (e instanceof Function) {
123
+ const t = e();
124
+ Symbol.asyncIterator in t ? this._iterator = t : this._iterator = async function* () {
125
+ let n = [];
126
+ for (; ; ) {
127
+ const r = t.next(...n);
128
+ if (r.done)
129
+ return r.value;
130
+ n = [yield r.value];
131
+ }
132
+ }();
133
+ } else if (Symbol.asyncIterator in e)
134
+ this._iterator = e[Symbol.asyncIterator]();
135
+ else if (Symbol.iterator in e) {
136
+ const t = e[Symbol.iterator]();
137
+ this._iterator = async function* () {
138
+ for (; ; ) {
139
+ const n = t.next();
140
+ if (n.done)
141
+ return n.value;
142
+ yield n.value;
143
+ }
144
+ }();
145
+ } else
146
+ this._iterator = async function* () {
147
+ let t = [];
148
+ for (; ; ) {
149
+ const n = await e.next(...t);
150
+ if (n.done)
151
+ return n.value;
152
+ t = [yield n.value];
153
+ }
154
+ }();
155
+ this._iterator.return && (this.return = (t) => this._iterator.return(t)), this._iterator.throw && (this.throw = (t) => this._iterator.throw(t));
123
156
  }
124
157
  async every(e) {
125
158
  let t = 0;
@@ -145,7 +178,7 @@ class f {
145
178
  }
146
179
  filter(e) {
147
180
  const t = this._iterator;
148
- return new f(async function* () {
181
+ return new h(async function* () {
149
182
  let n = 0;
150
183
  for (; ; ) {
151
184
  const r = await t.next();
@@ -157,7 +190,7 @@ class f {
157
190
  }
158
191
  map(e) {
159
192
  const t = this._iterator;
160
- return new f(async function* () {
193
+ return new h(async function* () {
161
194
  let n = 0;
162
195
  for (; ; ) {
163
196
  const r = await t.next();
@@ -187,7 +220,7 @@ class f {
187
220
  }
188
221
  unique() {
189
222
  const e = this._iterator;
190
- return new f(async function* () {
223
+ return new h(async function* () {
191
224
  const t = /* @__PURE__ */ new Set();
192
225
  for (; ; ) {
193
226
  const n = await e.next();
@@ -233,6 +266,83 @@ class f {
233
266
  return this;
234
267
  }
235
268
  }
269
+ class f extends Error {
270
+ static FromUnknown(e) {
271
+ if (e instanceof f)
272
+ return e;
273
+ if (e instanceof Error) {
274
+ const t = new f(e.message);
275
+ return t.stack = e.stack, t.name = e.name, t;
276
+ }
277
+ return new f(`${e}`);
278
+ }
279
+ constructor(e, t, n = "Exception") {
280
+ super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
281
+
282
+ Caused by ${t.stack}` : this.stack += `
283
+
284
+ Caused by ${t}`);
285
+ }
286
+ get [Symbol.toStringTag]() {
287
+ return "Exception";
288
+ }
289
+ }
290
+ class P extends f {
291
+ constructor(e, t, n = "FatalErrorException") {
292
+ e === void 0 && (e = "The routine has encountered an unrecoverable error and cannot continue as expected. Please, refresh the page and try again. If the problem persists, contact the support team."), super(e, t, n);
293
+ }
294
+ get [Symbol.toStringTag]() {
295
+ return "FatalErrorException";
296
+ }
297
+ }
298
+ class F extends f {
299
+ constructor(e, t, n = "FileNotFoundException") {
300
+ super(e, t, n);
301
+ }
302
+ get [Symbol.toStringTag]() {
303
+ return "FileNotFoundException";
304
+ }
305
+ }
306
+ class k extends f {
307
+ constructor(e, t, n = "ReferenceException") {
308
+ super(e, t, n);
309
+ }
310
+ get [Symbol.toStringTag]() {
311
+ return "ReferenceException";
312
+ }
313
+ }
314
+ class R extends f {
315
+ constructor(e, t, n = "RuntimeException") {
316
+ super(e, t, n);
317
+ }
318
+ get [Symbol.toStringTag]() {
319
+ return "RuntimeException";
320
+ }
321
+ }
322
+ class T extends f {
323
+ constructor(e, t, n = "TimeoutException") {
324
+ super(e, t, n);
325
+ }
326
+ get [Symbol.toStringTag]() {
327
+ return "TimeoutException";
328
+ }
329
+ }
330
+ class M extends f {
331
+ constructor(e, t, n = "TypeException") {
332
+ super(e, t, n);
333
+ }
334
+ get [Symbol.toStringTag]() {
335
+ return "TypeException";
336
+ }
337
+ }
338
+ class m extends f {
339
+ constructor(e, t, n = "ValueException") {
340
+ super(e, t, n);
341
+ }
342
+ get [Symbol.toStringTag]() {
343
+ return "ValueException";
344
+ }
345
+ }
236
346
  class c {
237
347
  constructor(e) {
238
348
  u(this, "_elements");
@@ -252,6 +362,20 @@ class c {
252
362
  yield [r, e(r, s, n)];
253
363
  });
254
364
  }
365
+ reduce(e, t) {
366
+ let n = 0, r;
367
+ if (t !== void 0)
368
+ r = t;
369
+ else {
370
+ const s = this._elements.next();
371
+ if (s.done)
372
+ throw new M("Reduce of empty iterator with no initial value");
373
+ n += 1, r = s.value[1];
374
+ }
375
+ for (const [s, i] of this._elements)
376
+ r = e(s, r, i, n), n += 1;
377
+ return r;
378
+ }
255
379
  keys() {
256
380
  const e = this._elements;
257
381
  return new a(function* () {
@@ -390,8 +514,9 @@ class d {
390
514
  keys() {
391
515
  const e = this._elements;
392
516
  return new a(function* () {
393
- for (const [t] of e)
394
- yield t;
517
+ const t = /* @__PURE__ */ new Set();
518
+ for (const [n] of e)
519
+ t.has(n) || (t.add(n), yield n);
395
520
  });
396
521
  }
397
522
  items() {
@@ -427,19 +552,19 @@ class d {
427
552
  return "AggregatedIterator";
428
553
  }
429
554
  }
430
- class y {
555
+ class w {
431
556
  constructor(e) {
432
557
  u(this, "_elements");
433
558
  this._elements = new a(e);
434
559
  }
435
560
  filter(e) {
436
- return new y(this._elements.filter(e));
561
+ return new w(this._elements.filter(e));
437
562
  }
438
563
  map(e) {
439
- return new y(this._elements.map(e));
564
+ return new w(this._elements.map(e));
440
565
  }
441
566
  unique() {
442
- return new y(this._elements.unique());
567
+ return new w(this._elements.unique());
443
568
  }
444
569
  groupBy(e) {
445
570
  return new d(this._elements.map((t, n) => [e(t, n), t]));
@@ -448,10 +573,10 @@ class y {
448
573
  return "Aggregator";
449
574
  }
450
575
  }
451
- class w {
576
+ class y {
452
577
  constructor(e) {
453
578
  u(this, "_elements");
454
- this._elements = new f(e);
579
+ this._elements = new h(e);
455
580
  }
456
581
  async every(e) {
457
582
  const t = /* @__PURE__ */ new Map();
@@ -477,17 +602,17 @@ class w {
477
602
  }
478
603
  filter(e) {
479
604
  const t = this._elements;
480
- return new w(async function* () {
605
+ return new y(async function* () {
481
606
  const n = /* @__PURE__ */ new Map();
482
607
  for await (const [r, s] of t) {
483
608
  const i = n.get(r) ?? 0;
484
- n.set(r, i + 1), e(r, s, i) && (yield [r, s]);
609
+ n.set(r, i + 1), await e(r, s, i) && (yield [r, s]);
485
610
  }
486
611
  });
487
612
  }
488
613
  map(e) {
489
614
  const t = this._elements;
490
- return new w(async function* () {
615
+ return new y(async function* () {
491
616
  const n = /* @__PURE__ */ new Map();
492
617
  for await (const [r, s] of t) {
493
618
  const i = n.get(r) ?? 0;
@@ -502,7 +627,7 @@ class w {
502
627
  if (n.has(r))
503
628
  [i, l] = n.get(r), i += 1;
504
629
  else if (t !== void 0)
505
- i = 0, l = t(r);
630
+ i = 0, l = await t(r);
506
631
  else {
507
632
  n.set(r, [0, s]);
508
633
  continue;
@@ -516,7 +641,7 @@ class w {
516
641
  }
517
642
  unique() {
518
643
  const e = this._elements;
519
- return new w(async function* () {
644
+ return new y(async function* () {
520
645
  const t = /* @__PURE__ */ new Map();
521
646
  for await (const [n, r] of e) {
522
647
  const s = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -555,9 +680,10 @@ class w {
555
680
  }
556
681
  keys() {
557
682
  const e = this._elements;
558
- return new f(async function* () {
559
- for await (const [t] of e)
560
- yield t;
683
+ return new h(async function* () {
684
+ const t = /* @__PURE__ */ new Set();
685
+ for await (const [n] of e)
686
+ t.has(n) || (t.add(n), yield n);
561
687
  });
562
688
  }
563
689
  items() {
@@ -565,7 +691,7 @@ class w {
565
691
  }
566
692
  values() {
567
693
  const e = this._elements;
568
- return new f(async function* () {
694
+ return new h(async function* () {
569
695
  for await (const [t, n] of e)
570
696
  yield n;
571
697
  });
@@ -597,7 +723,7 @@ class w {
597
723
  class _ {
598
724
  constructor(e) {
599
725
  u(this, "_elements");
600
- this._elements = new f(e);
726
+ this._elements = new h(e);
601
727
  }
602
728
  filter(e) {
603
729
  return new _(this._elements.filter(e));
@@ -609,58 +735,13 @@ class _ {
609
735
  return new _(this._elements.unique());
610
736
  }
611
737
  groupBy(e) {
612
- return new w(this._elements.map(async (t, n) => [await e(t, n), t]));
738
+ return new y(this._elements.map(async (t, n) => [await e(t, n), t]));
613
739
  }
614
740
  get [Symbol.toStringTag]() {
615
741
  return "AsyncAggregator";
616
742
  }
617
743
  }
618
- class h extends Error {
619
- static FromUnknown(e) {
620
- if (e instanceof h)
621
- return e;
622
- if (e instanceof Error) {
623
- const t = new h(e.message);
624
- return t.stack = e.stack, t.name = e.name, t;
625
- }
626
- return new h(`${e}`);
627
- }
628
- constructor(e, t, n = "Exception") {
629
- super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
630
-
631
- Caused by ${t.stack}` : this.stack += `
632
-
633
- Caused by ${t}`);
634
- }
635
- get [Symbol.toStringTag]() {
636
- return "Exception";
637
- }
638
- }
639
- class b extends h {
640
- constructor(e, t, n = "ReferenceException") {
641
- super(e, t, n);
642
- }
643
- get [Symbol.toStringTag]() {
644
- return "ReferenceException";
645
- }
646
- }
647
- class M extends h {
648
- constructor(e, t, n = "TimeoutException") {
649
- super(e, t, n);
650
- }
651
- get [Symbol.toStringTag]() {
652
- return "TimeoutException";
653
- }
654
- }
655
- class m extends h {
656
- constructor(e, t, n = "ValueException") {
657
- super(e, t, n);
658
- }
659
- get [Symbol.toStringTag]() {
660
- return "ValueException";
661
- }
662
- }
663
- class E {
744
+ class q {
664
745
  constructor(e = !0) {
665
746
  u(this, "_preferPersistence");
666
747
  u(this, "_volatile");
@@ -798,7 +879,7 @@ class E {
798
879
  return "JsonStorage";
799
880
  }
800
881
  }
801
- class I {
882
+ class A {
802
883
  constructor() {
803
884
  u(this, "_subscribers");
804
885
  this._subscribers = [];
@@ -809,7 +890,7 @@ class I {
809
890
  remove(e) {
810
891
  const t = this._subscribers.indexOf(e);
811
892
  if (t < 0)
812
- throw new b("Unable to remove the requested subscriber. It was not found.");
893
+ throw new k("Unable to remove the requested subscriber. It was not found.");
813
894
  this._subscribers.splice(t, 1);
814
895
  }
815
896
  call(...e) {
@@ -819,7 +900,7 @@ class I {
819
900
  return "Subscribers";
820
901
  }
821
902
  }
822
- class v {
903
+ class g {
823
904
  constructor(e) {
824
905
  u(this, "_isPending");
825
906
  u(this, "_isFulfilled");
@@ -853,7 +934,7 @@ class v {
853
934
  return "SmartPromise";
854
935
  }
855
936
  }
856
- class R extends v {
937
+ class O extends g {
857
938
  constructor(t, n) {
858
939
  let r, s;
859
940
  super((i, l) => {
@@ -876,14 +957,14 @@ class R extends v {
876
957
  return "DeferredPromise";
877
958
  }
878
959
  }
879
- class q extends v {
960
+ class $ extends g {
880
961
  constructor(e, t) {
881
962
  super((n, r) => {
882
- const s = (g) => {
883
- clearTimeout(p), n(g);
884
- }, i = (g) => {
885
- clearTimeout(p), r(g);
886
- }, p = setTimeout(() => i(new M("The operation has timed out.")), t);
963
+ const s = (p) => {
964
+ clearTimeout(x), n(p);
965
+ }, i = (p) => {
966
+ clearTimeout(x), r(p);
967
+ }, x = setTimeout(() => i(new T("The operation has timed out.")), t);
887
968
  e(s, i);
888
969
  });
889
970
  }
@@ -891,7 +972,7 @@ class q extends v {
891
972
  return "TimedPromise";
892
973
  }
893
974
  }
894
- class x {
975
+ class v {
895
976
  static Boolean(e = 0.5) {
896
977
  return Math.random() < e;
897
978
  }
@@ -907,23 +988,23 @@ class x {
907
988
  return this.Integer(e.length);
908
989
  }
909
990
  static Choice(e) {
910
- return e[x.Index(e)];
991
+ return e[v.Index(e)];
911
992
  }
912
993
  // eslint-disable-next-line no-useless-constructor
913
994
  constructor() {
914
995
  }
915
996
  }
916
- async function F(o) {
997
+ async function C(o) {
917
998
  return new Promise((e, t) => setTimeout(e, o));
918
999
  }
919
- async function A() {
1000
+ async function Y() {
920
1001
  return new Promise((o, e) => requestAnimationFrame(() => o()));
921
1002
  }
922
- var T = /* @__PURE__ */ ((o) => (o[o.Second = 1e3] = "Second", o[o.Minute = 6e4] = "Minute", o[o.Hour = 36e5] = "Hour", o[o.Day = 864e5] = "Day", o[o.Week = 6048e5] = "Week", o[o.Month = 2592e6] = "Month", o[o.Year = 31536e6] = "Year", o))(T || {});
923
- function O(o, e, t = 864e5) {
1003
+ var E = /* @__PURE__ */ ((o) => (o[o.Second = 1e3] = "Second", o[o.Minute = 6e4] = "Minute", o[o.Hour = 36e5] = "Hour", o[o.Day = 864e5] = "Day", o[o.Week = 6048e5] = "Week", o[o.Month = 2592e6] = "Month", o[o.Year = 31536e6] = "Year", o))(E || {});
1004
+ function z(o, e, t = 864e5) {
924
1005
  return Math.floor((e.getTime() - o.getTime()) / t);
925
1006
  }
926
- function $(o, e, t = 864e5) {
1007
+ function J(o, e, t = 864e5) {
927
1008
  return new a(function* () {
928
1009
  const n = e.getTime();
929
1010
  let r = o.getTime();
@@ -931,16 +1012,16 @@ function $(o, e, t = 864e5) {
931
1012
  yield new Date(r), r += t;
932
1013
  });
933
1014
  }
934
- function C(o, e = 864e5) {
1015
+ function V(o, e = 864e5) {
935
1016
  return new Date(Math.floor(o.getTime() / e) * e);
936
1017
  }
937
- function V(o, e = "text/javascript") {
1018
+ function B(o, e = "text/javascript") {
938
1019
  return new Promise((t, n) => {
939
1020
  const r = document.createElement("script");
940
1021
  r.async = !0, r.defer = !0, r.src = o, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
941
1022
  });
942
1023
  }
943
- function Y(o) {
1024
+ function H(o) {
944
1025
  if (Array.isArray(o))
945
1026
  return o.length;
946
1027
  let e = 0;
@@ -948,14 +1029,14 @@ function Y(o) {
948
1029
  e += 1;
949
1030
  return e;
950
1031
  }
951
- function z(o, e, t = 1) {
1032
+ function W(o, e, t = 1) {
952
1033
  return new a(function* () {
953
1034
  e === void 0 && (e = o, o = 0), o > e && (t = t ?? -1);
954
1035
  for (let n = o; n < e; n += t)
955
1036
  yield n;
956
1037
  });
957
1038
  }
958
- function J(o) {
1039
+ function G(o) {
959
1040
  const e = Array.from(o);
960
1041
  for (let t = e.length - 1; t > 0; t -= 1) {
961
1042
  const n = Math.floor(Math.random() * (t + 1));
@@ -963,7 +1044,7 @@ function J(o) {
963
1044
  }
964
1045
  return e;
965
1046
  }
966
- function B(o) {
1047
+ function K(o) {
967
1048
  return new a(function* () {
968
1049
  const e = /* @__PURE__ */ new Set();
969
1050
  for (const t of o)
@@ -981,7 +1062,7 @@ function j(o, e) {
981
1062
  }
982
1063
  });
983
1064
  }
984
- function H(o, e) {
1065
+ function L(o, e) {
985
1066
  if (e === void 0) {
986
1067
  let s = 0, i = 0;
987
1068
  for (const l of o)
@@ -1002,7 +1083,7 @@ function H(o, e) {
1002
1083
  throw new m("The sum of weights must be greater than zero.");
1003
1084
  return t / n;
1004
1085
  }
1005
- function W(o) {
1086
+ function N(o) {
1006
1087
  let e = 0;
1007
1088
  for (let t = 0; t < o.length; t += 1) {
1008
1089
  const n = o.charCodeAt(t);
@@ -1010,50 +1091,53 @@ function W(o) {
1010
1091
  }
1011
1092
  return e;
1012
1093
  }
1013
- function G(o) {
1094
+ function Q(o) {
1014
1095
  let e = 0;
1015
1096
  for (const t of o)
1016
1097
  e += t;
1017
1098
  return e;
1018
1099
  }
1019
- function K(o) {
1100
+ function X(o) {
1020
1101
  return `${o.charAt(0).toUpperCase()}${o.slice(1)}`;
1021
1102
  }
1022
- const L = "1.5.0-rc.6";
1103
+ const Z = "1.5.0-rc.7";
1023
1104
  export {
1024
- w as AggregatedAsyncIterator,
1105
+ y as AggregatedAsyncIterator,
1025
1106
  d as AggregatedIterator,
1026
- y as Aggregator,
1107
+ w as Aggregator,
1027
1108
  _ as AsyncAggregator,
1028
- T as DateUnit,
1029
- R as DeferredPromise,
1030
- h as Exception,
1031
- E as JsonStorage,
1032
- x as Random,
1109
+ E as DateUnit,
1110
+ O as DeferredPromise,
1111
+ f as Exception,
1112
+ P as FatalErrorException,
1113
+ F as FileNotFoundException,
1114
+ q as JsonStorage,
1115
+ v as Random,
1033
1116
  c as ReducedIterator,
1034
- b as ReferenceException,
1035
- f as SmartAsyncIterator,
1117
+ R as RuntimeException,
1118
+ h as SmartAsyncIterator,
1036
1119
  a as SmartIterator,
1037
- v as SmartPromise,
1038
- I as Subscribers,
1039
- q as TimedPromise,
1040
- M as TimeoutException,
1041
- L as VERSION,
1120
+ g as SmartPromise,
1121
+ A as Subscribers,
1122
+ $ as TimedPromise,
1123
+ T as TimeoutException,
1124
+ M as TypeException,
1125
+ Z as VERSION,
1042
1126
  m as ValueException,
1043
- H as average,
1044
- K as capitalize,
1045
- Y as count,
1046
- O as dateDifference,
1047
- $ as dateRange,
1048
- C as dateRound,
1049
- F as delay,
1050
- W as hash,
1051
- V as loadScript,
1052
- A as nextAnimationFrame,
1053
- z as range,
1054
- J as shuffle,
1055
- G as sum,
1056
- B as unique,
1127
+ L as average,
1128
+ X as capitalize,
1129
+ H as count,
1130
+ z as dateDifference,
1131
+ J as dateRange,
1132
+ V as dateRound,
1133
+ C as delay,
1134
+ N as hash,
1135
+ B as loadScript,
1136
+ Y as nextAnimationFrame,
1137
+ W as range,
1138
+ G as shuffle,
1139
+ Q as sum,
1140
+ K as unique,
1057
1141
  j as zip
1058
1142
  };
1059
1143
  //# sourceMappingURL=core.js.map