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

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 k = (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) => k(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  class a {
5
5
  constructor(e) {
6
6
  u(this, "_iterator");
@@ -114,7 +114,7 @@ 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");
@@ -145,7 +145,7 @@ class f {
145
145
  }
146
146
  filter(e) {
147
147
  const t = this._iterator;
148
- return new f(async function* () {
148
+ return new h(async function* () {
149
149
  let n = 0;
150
150
  for (; ; ) {
151
151
  const r = await t.next();
@@ -157,7 +157,7 @@ class f {
157
157
  }
158
158
  map(e) {
159
159
  const t = this._iterator;
160
- return new f(async function* () {
160
+ return new h(async function* () {
161
161
  let n = 0;
162
162
  for (; ; ) {
163
163
  const r = await t.next();
@@ -187,7 +187,7 @@ class f {
187
187
  }
188
188
  unique() {
189
189
  const e = this._iterator;
190
- return new f(async function* () {
190
+ return new h(async function* () {
191
191
  const t = /* @__PURE__ */ new Set();
192
192
  for (; ; ) {
193
193
  const n = await e.next();
@@ -233,25 +233,39 @@ class f {
233
233
  return this;
234
234
  }
235
235
  }
236
- class c {
236
+ class l {
237
237
  constructor(e) {
238
238
  u(this, "_elements");
239
239
  this._elements = new a(e);
240
240
  }
241
241
  filter(e) {
242
242
  const t = this._elements;
243
- return new c(function* () {
243
+ return new l(function* () {
244
244
  for (const [n, [r, s]] of t.enumerate())
245
245
  e(r, s, n) && (yield [r, s]);
246
246
  });
247
247
  }
248
248
  map(e) {
249
249
  const t = this._elements;
250
- return new c(function* () {
250
+ return new l(function* () {
251
251
  for (const [n, [r, s]] of t.enumerate())
252
252
  yield [r, e(r, s, n)];
253
253
  });
254
254
  }
255
+ reduce(e, t) {
256
+ let n = 0, r;
257
+ if (t !== void 0)
258
+ r = t;
259
+ else {
260
+ const s = this._elements.next();
261
+ if (s.done)
262
+ throw new TypeError("Reduce of empty iterator with no initial value");
263
+ n += 1, r = s.value[1];
264
+ }
265
+ for (const [s, i] of this._elements)
266
+ r = e(s, r, i, n), n += 1;
267
+ return r;
268
+ }
255
269
  keys() {
256
270
  const e = this._elements;
257
271
  return new a(function* () {
@@ -293,7 +307,7 @@ class d {
293
307
  const [s, i] = t.get(n) ?? [0, !0];
294
308
  i && t.set(n, [s + 1, e(n, r, s)]);
295
309
  }
296
- return new c(function* () {
310
+ return new l(function* () {
297
311
  for (const [n, [r, s]] of t)
298
312
  yield [n, s];
299
313
  });
@@ -304,7 +318,7 @@ class d {
304
318
  const [s, i] = t.get(n) ?? [0, !1];
305
319
  i || t.set(n, [s + 1, e(n, r, s)]);
306
320
  }
307
- return new c(function* () {
321
+ return new l(function* () {
308
322
  for (const [n, [r, s]] of t)
309
323
  yield [n, s];
310
324
  });
@@ -332,18 +346,18 @@ class d {
332
346
  reduce(e, t) {
333
347
  const n = /* @__PURE__ */ new Map();
334
348
  for (const [r, s] of this._elements) {
335
- let i, l;
349
+ let i, c;
336
350
  if (n.has(r))
337
- [i, l] = n.get(r), i += 1;
351
+ [i, c] = n.get(r), i += 1;
338
352
  else if (t !== void 0)
339
- i = 0, l = t(r);
353
+ i = 0, c = t(r);
340
354
  else {
341
355
  n.set(r, [0, s]);
342
356
  continue;
343
357
  }
344
- l = e(r, l, s, i), n.set(r, [i, l]);
358
+ c = e(r, c, s, i), n.set(r, [i, c]);
345
359
  }
346
- return new c(function* () {
360
+ return new l(function* () {
347
361
  for (const [r, [s, i]] of n)
348
362
  yield [r, i];
349
363
  });
@@ -364,7 +378,7 @@ class d {
364
378
  const n = e.get(t) ?? 0;
365
379
  e.set(t, n + 1);
366
380
  }
367
- return new c(function* () {
381
+ return new l(function* () {
368
382
  for (const [t, n] of e)
369
383
  yield [t, n];
370
384
  });
@@ -373,7 +387,7 @@ class d {
373
387
  const e = /* @__PURE__ */ new Map();
374
388
  for (const [t, n] of this._elements)
375
389
  e.has(t) || e.set(t, n);
376
- return new c(function* () {
390
+ return new l(function* () {
377
391
  for (const [t, n] of e)
378
392
  yield [t, n];
379
393
  });
@@ -382,7 +396,7 @@ class d {
382
396
  const e = /* @__PURE__ */ new Map();
383
397
  for (const [t, n] of this._elements)
384
398
  e.set(t, n);
385
- return new c(function* () {
399
+ return new l(function* () {
386
400
  for (const [t, n] of e)
387
401
  yield [t, n];
388
402
  });
@@ -390,8 +404,9 @@ class d {
390
404
  keys() {
391
405
  const e = this._elements;
392
406
  return new a(function* () {
393
- for (const [t] of e)
394
- yield t;
407
+ const t = /* @__PURE__ */ new Set();
408
+ for (const [n] of e)
409
+ t.has(n) || (t.add(n), yield n);
395
410
  });
396
411
  }
397
412
  items() {
@@ -451,7 +466,7 @@ class y {
451
466
  class w {
452
467
  constructor(e) {
453
468
  u(this, "_elements");
454
- this._elements = new f(e);
469
+ this._elements = new h(e);
455
470
  }
456
471
  async every(e) {
457
472
  const t = /* @__PURE__ */ new Map();
@@ -459,7 +474,7 @@ class w {
459
474
  const [s, i] = t.get(n) ?? [0, !0];
460
475
  i && t.set(n, [s + 1, await e(n, r, s)]);
461
476
  }
462
- return new c(function* () {
477
+ return new l(function* () {
463
478
  for (const [n, [r, s]] of t)
464
479
  yield [n, s];
465
480
  });
@@ -470,7 +485,7 @@ class w {
470
485
  const [s, i] = t.get(n) ?? [0, !1];
471
486
  i || t.set(n, [s + 1, await e(n, r, s)]);
472
487
  }
473
- return new c(function* () {
488
+ return new l(function* () {
474
489
  for (const [n, [r, s]] of t)
475
490
  yield [n, s];
476
491
  });
@@ -498,18 +513,18 @@ class w {
498
513
  async reduce(e, t) {
499
514
  const n = /* @__PURE__ */ new Map();
500
515
  for await (const [r, s] of this._elements) {
501
- let i, l;
516
+ let i, c;
502
517
  if (n.has(r))
503
- [i, l] = n.get(r), i += 1;
518
+ [i, c] = n.get(r), i += 1;
504
519
  else if (t !== void 0)
505
- i = 0, l = t(r);
520
+ i = 0, c = t(r);
506
521
  else {
507
522
  n.set(r, [0, s]);
508
523
  continue;
509
524
  }
510
- l = await e(r, l, s, i), n.set(r, [i, l]);
525
+ c = await e(r, c, s, i), n.set(r, [i, c]);
511
526
  }
512
- return new c(function* () {
527
+ return new l(function* () {
513
528
  for (const [r, [s, i]] of n)
514
529
  yield [r, i];
515
530
  });
@@ -530,7 +545,7 @@ class w {
530
545
  const n = e.get(t) ?? 0;
531
546
  e.set(t, n + 1);
532
547
  }
533
- return new c(function* () {
548
+ return new l(function* () {
534
549
  for (const [t, n] of e)
535
550
  yield [t, n];
536
551
  });
@@ -539,7 +554,7 @@ class w {
539
554
  const e = /* @__PURE__ */ new Map();
540
555
  for await (const [t, n] of this._elements)
541
556
  e.has(t) || e.set(t, n);
542
- return new c(function* () {
557
+ return new l(function* () {
543
558
  for (const [t, n] of e)
544
559
  yield [t, n];
545
560
  });
@@ -548,16 +563,17 @@ class w {
548
563
  const e = /* @__PURE__ */ new Map();
549
564
  for await (const [t, n] of this._elements)
550
565
  e.set(t, n);
551
- return new c(function* () {
566
+ return new l(function* () {
552
567
  for (const [t, n] of e)
553
568
  yield [t, n];
554
569
  });
555
570
  }
556
571
  keys() {
557
572
  const e = this._elements;
558
- return new f(async function* () {
559
- for await (const [t] of e)
560
- yield t;
573
+ return new h(async function* () {
574
+ const t = /* @__PURE__ */ new Set();
575
+ for await (const [n] of e)
576
+ t.has(n) || (t.add(n), yield n);
561
577
  });
562
578
  }
563
579
  items() {
@@ -565,7 +581,7 @@ class w {
565
581
  }
566
582
  values() {
567
583
  const e = this._elements;
568
- return new f(async function* () {
584
+ return new h(async function* () {
569
585
  for await (const [t, n] of e)
570
586
  yield n;
571
587
  });
@@ -597,7 +613,7 @@ class w {
597
613
  class _ {
598
614
  constructor(e) {
599
615
  u(this, "_elements");
600
- this._elements = new f(e);
616
+ this._elements = new h(e);
601
617
  }
602
618
  filter(e) {
603
619
  return new _(this._elements.filter(e));
@@ -615,15 +631,15 @@ class _ {
615
631
  return "AsyncAggregator";
616
632
  }
617
633
  }
618
- class h extends Error {
634
+ class f extends Error {
619
635
  static FromUnknown(e) {
620
- if (e instanceof h)
636
+ if (e instanceof f)
621
637
  return e;
622
638
  if (e instanceof Error) {
623
- const t = new h(e.message);
639
+ const t = new f(e.message);
624
640
  return t.stack = e.stack, t.name = e.name, t;
625
641
  }
626
- return new h(`${e}`);
642
+ return new f(`${e}`);
627
643
  }
628
644
  constructor(e, t, n = "Exception") {
629
645
  super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
@@ -636,7 +652,23 @@ Caused by ${t}`);
636
652
  return "Exception";
637
653
  }
638
654
  }
639
- class b extends h {
655
+ class P extends f {
656
+ constructor(e, t, n = "FatalErrorException") {
657
+ 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);
658
+ }
659
+ get [Symbol.toStringTag]() {
660
+ return "FatalErrorException";
661
+ }
662
+ }
663
+ class F extends f {
664
+ constructor(e, t, n = "FileNotFoundException") {
665
+ super(e, t, n);
666
+ }
667
+ get [Symbol.toStringTag]() {
668
+ return "FileNotFoundException";
669
+ }
670
+ }
671
+ class b extends f {
640
672
  constructor(e, t, n = "ReferenceException") {
641
673
  super(e, t, n);
642
674
  }
@@ -644,7 +676,15 @@ class b extends h {
644
676
  return "ReferenceException";
645
677
  }
646
678
  }
647
- class M extends h {
679
+ class I extends f {
680
+ constructor(e, t, n = "RuntimeException") {
681
+ super(e, t, n);
682
+ }
683
+ get [Symbol.toStringTag]() {
684
+ return "RuntimeException";
685
+ }
686
+ }
687
+ class T extends f {
648
688
  constructor(e, t, n = "TimeoutException") {
649
689
  super(e, t, n);
650
690
  }
@@ -652,7 +692,15 @@ class M extends h {
652
692
  return "TimeoutException";
653
693
  }
654
694
  }
655
- class m extends h {
695
+ class R extends f {
696
+ constructor(e, t, n = "TypeException") {
697
+ super(e, t, n);
698
+ }
699
+ get [Symbol.toStringTag]() {
700
+ return "TypeException";
701
+ }
702
+ }
703
+ class m extends f {
656
704
  constructor(e, t, n = "ValueException") {
657
705
  super(e, t, n);
658
706
  }
@@ -660,7 +708,7 @@ class m extends h {
660
708
  return "ValueException";
661
709
  }
662
710
  }
663
- class E {
711
+ class q {
664
712
  constructor(e = !0) {
665
713
  u(this, "_preferPersistence");
666
714
  u(this, "_volatile");
@@ -798,7 +846,7 @@ class E {
798
846
  return "JsonStorage";
799
847
  }
800
848
  }
801
- class I {
849
+ class A {
802
850
  constructor() {
803
851
  u(this, "_subscribers");
804
852
  this._subscribers = [];
@@ -819,7 +867,7 @@ class I {
819
867
  return "Subscribers";
820
868
  }
821
869
  }
822
- class v {
870
+ class x {
823
871
  constructor(e) {
824
872
  u(this, "_isPending");
825
873
  u(this, "_isFulfilled");
@@ -853,11 +901,11 @@ class v {
853
901
  return "SmartPromise";
854
902
  }
855
903
  }
856
- class R extends v {
904
+ class O extends x {
857
905
  constructor(t, n) {
858
906
  let r, s;
859
- super((i, l) => {
860
- r = i, s = l;
907
+ super((i, c) => {
908
+ r = i, s = c;
861
909
  });
862
910
  u(this, "_resolve");
863
911
  u(this, "_reject");
@@ -876,14 +924,14 @@ class R extends v {
876
924
  return "DeferredPromise";
877
925
  }
878
926
  }
879
- class q extends v {
927
+ class $ extends x {
880
928
  constructor(e, t) {
881
929
  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);
930
+ const s = (p) => {
931
+ clearTimeout(g), n(p);
932
+ }, i = (p) => {
933
+ clearTimeout(g), r(p);
934
+ }, g = setTimeout(() => i(new T("The operation has timed out.")), t);
887
935
  e(s, i);
888
936
  });
889
937
  }
@@ -891,7 +939,7 @@ class q extends v {
891
939
  return "TimedPromise";
892
940
  }
893
941
  }
894
- class x {
942
+ class v {
895
943
  static Boolean(e = 0.5) {
896
944
  return Math.random() < e;
897
945
  }
@@ -907,23 +955,23 @@ class x {
907
955
  return this.Integer(e.length);
908
956
  }
909
957
  static Choice(e) {
910
- return e[x.Index(e)];
958
+ return e[v.Index(e)];
911
959
  }
912
960
  // eslint-disable-next-line no-useless-constructor
913
961
  constructor() {
914
962
  }
915
963
  }
916
- async function F(o) {
964
+ async function C(o) {
917
965
  return new Promise((e, t) => setTimeout(e, o));
918
966
  }
919
- async function A() {
967
+ async function Y() {
920
968
  return new Promise((o, e) => requestAnimationFrame(() => o()));
921
969
  }
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) {
970
+ var M = /* @__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))(M || {});
971
+ function z(o, e, t = 864e5) {
924
972
  return Math.floor((e.getTime() - o.getTime()) / t);
925
973
  }
926
- function $(o, e, t = 864e5) {
974
+ function J(o, e, t = 864e5) {
927
975
  return new a(function* () {
928
976
  const n = e.getTime();
929
977
  let r = o.getTime();
@@ -931,16 +979,16 @@ function $(o, e, t = 864e5) {
931
979
  yield new Date(r), r += t;
932
980
  });
933
981
  }
934
- function C(o, e = 864e5) {
982
+ function V(o, e = 864e5) {
935
983
  return new Date(Math.floor(o.getTime() / e) * e);
936
984
  }
937
- function V(o, e = "text/javascript") {
985
+ function B(o, e = "text/javascript") {
938
986
  return new Promise((t, n) => {
939
987
  const r = document.createElement("script");
940
988
  r.async = !0, r.defer = !0, r.src = o, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
941
989
  });
942
990
  }
943
- function Y(o) {
991
+ function H(o) {
944
992
  if (Array.isArray(o))
945
993
  return o.length;
946
994
  let e = 0;
@@ -948,14 +996,14 @@ function Y(o) {
948
996
  e += 1;
949
997
  return e;
950
998
  }
951
- function z(o, e, t = 1) {
999
+ function W(o, e, t = 1) {
952
1000
  return new a(function* () {
953
1001
  e === void 0 && (e = o, o = 0), o > e && (t = t ?? -1);
954
1002
  for (let n = o; n < e; n += t)
955
1003
  yield n;
956
1004
  });
957
1005
  }
958
- function J(o) {
1006
+ function G(o) {
959
1007
  const e = Array.from(o);
960
1008
  for (let t = e.length - 1; t > 0; t -= 1) {
961
1009
  const n = Math.floor(Math.random() * (t + 1));
@@ -963,14 +1011,14 @@ function J(o) {
963
1011
  }
964
1012
  return e;
965
1013
  }
966
- function B(o) {
1014
+ function K(o) {
967
1015
  return new a(function* () {
968
1016
  const e = /* @__PURE__ */ new Set();
969
1017
  for (const t of o)
970
1018
  e.has(t) || (e.add(t), yield t);
971
1019
  });
972
1020
  }
973
- function j(o, e) {
1021
+ function E(o, e) {
974
1022
  return new a(function* () {
975
1023
  const t = o[Symbol.iterator](), n = e[Symbol.iterator]();
976
1024
  for (; ; ) {
@@ -981,17 +1029,17 @@ function j(o, e) {
981
1029
  }
982
1030
  });
983
1031
  }
984
- function H(o, e) {
1032
+ function L(o, e) {
985
1033
  if (e === void 0) {
986
1034
  let s = 0, i = 0;
987
- for (const l of o)
988
- s += l, i += 1;
1035
+ for (const c of o)
1036
+ s += c, i += 1;
989
1037
  if (i === 0)
990
1038
  throw new m("You must provide at least one value.");
991
1039
  return s / i;
992
1040
  }
993
1041
  let t = 0, n = 0, r = 0;
994
- for (const [s, i] of j(o, e)) {
1042
+ for (const [s, i] of E(o, e)) {
995
1043
  if (i <= 0)
996
1044
  throw new m(`The weight for the value #${r} must be greater than zero.`);
997
1045
  t += s * i, n += i, r += 1;
@@ -1002,7 +1050,7 @@ function H(o, e) {
1002
1050
  throw new m("The sum of weights must be greater than zero.");
1003
1051
  return t / n;
1004
1052
  }
1005
- function W(o) {
1053
+ function N(o) {
1006
1054
  let e = 0;
1007
1055
  for (let t = 0; t < o.length; t += 1) {
1008
1056
  const n = o.charCodeAt(t);
@@ -1010,50 +1058,53 @@ function W(o) {
1010
1058
  }
1011
1059
  return e;
1012
1060
  }
1013
- function G(o) {
1061
+ function Q(o) {
1014
1062
  let e = 0;
1015
1063
  for (const t of o)
1016
1064
  e += t;
1017
1065
  return e;
1018
1066
  }
1019
- function K(o) {
1067
+ function X(o) {
1020
1068
  return `${o.charAt(0).toUpperCase()}${o.slice(1)}`;
1021
1069
  }
1022
- const L = "1.5.0-rc.6";
1070
+ const Z = "1.5.0-rc.7";
1023
1071
  export {
1024
1072
  w as AggregatedAsyncIterator,
1025
1073
  d as AggregatedIterator,
1026
1074
  y as Aggregator,
1027
1075
  _ as AsyncAggregator,
1028
- T as DateUnit,
1029
- R as DeferredPromise,
1030
- h as Exception,
1031
- E as JsonStorage,
1032
- x as Random,
1033
- c as ReducedIterator,
1034
- b as ReferenceException,
1035
- f as SmartAsyncIterator,
1076
+ M as DateUnit,
1077
+ O as DeferredPromise,
1078
+ f as Exception,
1079
+ P as FatalErrorException,
1080
+ F as FileNotFoundException,
1081
+ q as JsonStorage,
1082
+ v as Random,
1083
+ l as ReducedIterator,
1084
+ I as RuntimeException,
1085
+ h as SmartAsyncIterator,
1036
1086
  a as SmartIterator,
1037
- v as SmartPromise,
1038
- I as Subscribers,
1039
- q as TimedPromise,
1040
- M as TimeoutException,
1041
- L as VERSION,
1087
+ x as SmartPromise,
1088
+ A as Subscribers,
1089
+ $ as TimedPromise,
1090
+ T as TimeoutException,
1091
+ R as TypeException,
1092
+ Z as VERSION,
1042
1093
  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,
1057
- j as zip
1094
+ L as average,
1095
+ X as capitalize,
1096
+ H as count,
1097
+ z as dateDifference,
1098
+ J as dateRange,
1099
+ V as dateRound,
1100
+ C as delay,
1101
+ N as hash,
1102
+ B as loadScript,
1103
+ Y as nextAnimationFrame,
1104
+ W as range,
1105
+ G as shuffle,
1106
+ Q as sum,
1107
+ K as unique,
1108
+ E as zip
1058
1109
  };
1059
1110
  //# sourceMappingURL=core.js.map