@byloth/core 1.5.0-rc.7 → 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
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);
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");
@@ -119,7 +119,40 @@ class h {
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;
@@ -233,21 +266,98 @@ class h {
233
266
  return this;
234
267
  }
235
268
  }
236
- class l {
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
+ }
346
+ class c {
237
347
  constructor(e) {
238
348
  u(this, "_elements");
239
349
  this._elements = new a(e);
240
350
  }
241
351
  filter(e) {
242
352
  const t = this._elements;
243
- return new l(function* () {
353
+ return new c(function* () {
244
354
  for (const [n, [r, s]] of t.enumerate())
245
355
  e(r, s, n) && (yield [r, s]);
246
356
  });
247
357
  }
248
358
  map(e) {
249
359
  const t = this._elements;
250
- return new l(function* () {
360
+ return new c(function* () {
251
361
  for (const [n, [r, s]] of t.enumerate())
252
362
  yield [r, e(r, s, n)];
253
363
  });
@@ -259,7 +369,7 @@ class l {
259
369
  else {
260
370
  const s = this._elements.next();
261
371
  if (s.done)
262
- throw new TypeError("Reduce of empty iterator with no initial value");
372
+ throw new M("Reduce of empty iterator with no initial value");
263
373
  n += 1, r = s.value[1];
264
374
  }
265
375
  for (const [s, i] of this._elements)
@@ -307,7 +417,7 @@ class d {
307
417
  const [s, i] = t.get(n) ?? [0, !0];
308
418
  i && t.set(n, [s + 1, e(n, r, s)]);
309
419
  }
310
- return new l(function* () {
420
+ return new c(function* () {
311
421
  for (const [n, [r, s]] of t)
312
422
  yield [n, s];
313
423
  });
@@ -318,7 +428,7 @@ class d {
318
428
  const [s, i] = t.get(n) ?? [0, !1];
319
429
  i || t.set(n, [s + 1, e(n, r, s)]);
320
430
  }
321
- return new l(function* () {
431
+ return new c(function* () {
322
432
  for (const [n, [r, s]] of t)
323
433
  yield [n, s];
324
434
  });
@@ -346,18 +456,18 @@ class d {
346
456
  reduce(e, t) {
347
457
  const n = /* @__PURE__ */ new Map();
348
458
  for (const [r, s] of this._elements) {
349
- let i, c;
459
+ let i, l;
350
460
  if (n.has(r))
351
- [i, c] = n.get(r), i += 1;
461
+ [i, l] = n.get(r), i += 1;
352
462
  else if (t !== void 0)
353
- i = 0, c = t(r);
463
+ i = 0, l = t(r);
354
464
  else {
355
465
  n.set(r, [0, s]);
356
466
  continue;
357
467
  }
358
- c = e(r, c, s, i), n.set(r, [i, c]);
468
+ l = e(r, l, s, i), n.set(r, [i, l]);
359
469
  }
360
- return new l(function* () {
470
+ return new c(function* () {
361
471
  for (const [r, [s, i]] of n)
362
472
  yield [r, i];
363
473
  });
@@ -378,7 +488,7 @@ class d {
378
488
  const n = e.get(t) ?? 0;
379
489
  e.set(t, n + 1);
380
490
  }
381
- return new l(function* () {
491
+ return new c(function* () {
382
492
  for (const [t, n] of e)
383
493
  yield [t, n];
384
494
  });
@@ -387,7 +497,7 @@ class d {
387
497
  const e = /* @__PURE__ */ new Map();
388
498
  for (const [t, n] of this._elements)
389
499
  e.has(t) || e.set(t, n);
390
- return new l(function* () {
500
+ return new c(function* () {
391
501
  for (const [t, n] of e)
392
502
  yield [t, n];
393
503
  });
@@ -396,7 +506,7 @@ class d {
396
506
  const e = /* @__PURE__ */ new Map();
397
507
  for (const [t, n] of this._elements)
398
508
  e.set(t, n);
399
- return new l(function* () {
509
+ return new c(function* () {
400
510
  for (const [t, n] of e)
401
511
  yield [t, n];
402
512
  });
@@ -442,19 +552,19 @@ class d {
442
552
  return "AggregatedIterator";
443
553
  }
444
554
  }
445
- class y {
555
+ class w {
446
556
  constructor(e) {
447
557
  u(this, "_elements");
448
558
  this._elements = new a(e);
449
559
  }
450
560
  filter(e) {
451
- return new y(this._elements.filter(e));
561
+ return new w(this._elements.filter(e));
452
562
  }
453
563
  map(e) {
454
- return new y(this._elements.map(e));
564
+ return new w(this._elements.map(e));
455
565
  }
456
566
  unique() {
457
- return new y(this._elements.unique());
567
+ return new w(this._elements.unique());
458
568
  }
459
569
  groupBy(e) {
460
570
  return new d(this._elements.map((t, n) => [e(t, n), t]));
@@ -463,7 +573,7 @@ class y {
463
573
  return "Aggregator";
464
574
  }
465
575
  }
466
- class w {
576
+ class y {
467
577
  constructor(e) {
468
578
  u(this, "_elements");
469
579
  this._elements = new h(e);
@@ -474,7 +584,7 @@ class w {
474
584
  const [s, i] = t.get(n) ?? [0, !0];
475
585
  i && t.set(n, [s + 1, await e(n, r, s)]);
476
586
  }
477
- return new l(function* () {
587
+ return new c(function* () {
478
588
  for (const [n, [r, s]] of t)
479
589
  yield [n, s];
480
590
  });
@@ -485,24 +595,24 @@ class w {
485
595
  const [s, i] = t.get(n) ?? [0, !1];
486
596
  i || t.set(n, [s + 1, await e(n, r, s)]);
487
597
  }
488
- return new l(function* () {
598
+ return new c(function* () {
489
599
  for (const [n, [r, s]] of t)
490
600
  yield [n, s];
491
601
  });
492
602
  }
493
603
  filter(e) {
494
604
  const t = this._elements;
495
- return new w(async function* () {
605
+ return new y(async function* () {
496
606
  const n = /* @__PURE__ */ new Map();
497
607
  for await (const [r, s] of t) {
498
608
  const i = n.get(r) ?? 0;
499
- 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]);
500
610
  }
501
611
  });
502
612
  }
503
613
  map(e) {
504
614
  const t = this._elements;
505
- return new w(async function* () {
615
+ return new y(async function* () {
506
616
  const n = /* @__PURE__ */ new Map();
507
617
  for await (const [r, s] of t) {
508
618
  const i = n.get(r) ?? 0;
@@ -513,25 +623,25 @@ class w {
513
623
  async reduce(e, t) {
514
624
  const n = /* @__PURE__ */ new Map();
515
625
  for await (const [r, s] of this._elements) {
516
- let i, c;
626
+ let i, l;
517
627
  if (n.has(r))
518
- [i, c] = n.get(r), i += 1;
628
+ [i, l] = n.get(r), i += 1;
519
629
  else if (t !== void 0)
520
- i = 0, c = t(r);
630
+ i = 0, l = await t(r);
521
631
  else {
522
632
  n.set(r, [0, s]);
523
633
  continue;
524
634
  }
525
- c = await e(r, c, s, i), n.set(r, [i, c]);
635
+ l = await e(r, l, s, i), n.set(r, [i, l]);
526
636
  }
527
- return new l(function* () {
637
+ return new c(function* () {
528
638
  for (const [r, [s, i]] of n)
529
639
  yield [r, i];
530
640
  });
531
641
  }
532
642
  unique() {
533
643
  const e = this._elements;
534
- return new w(async function* () {
644
+ return new y(async function* () {
535
645
  const t = /* @__PURE__ */ new Map();
536
646
  for await (const [n, r] of e) {
537
647
  const s = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -545,7 +655,7 @@ class w {
545
655
  const n = e.get(t) ?? 0;
546
656
  e.set(t, n + 1);
547
657
  }
548
- return new l(function* () {
658
+ return new c(function* () {
549
659
  for (const [t, n] of e)
550
660
  yield [t, n];
551
661
  });
@@ -554,7 +664,7 @@ class w {
554
664
  const e = /* @__PURE__ */ new Map();
555
665
  for await (const [t, n] of this._elements)
556
666
  e.has(t) || e.set(t, n);
557
- return new l(function* () {
667
+ return new c(function* () {
558
668
  for (const [t, n] of e)
559
669
  yield [t, n];
560
670
  });
@@ -563,7 +673,7 @@ class w {
563
673
  const e = /* @__PURE__ */ new Map();
564
674
  for await (const [t, n] of this._elements)
565
675
  e.set(t, n);
566
- return new l(function* () {
676
+ return new c(function* () {
567
677
  for (const [t, n] of e)
568
678
  yield [t, n];
569
679
  });
@@ -625,89 +735,12 @@ class _ {
625
735
  return new _(this._elements.unique());
626
736
  }
627
737
  groupBy(e) {
628
- 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]));
629
739
  }
630
740
  get [Symbol.toStringTag]() {
631
741
  return "AsyncAggregator";
632
742
  }
633
743
  }
634
- class f extends Error {
635
- static FromUnknown(e) {
636
- if (e instanceof f)
637
- return e;
638
- if (e instanceof Error) {
639
- const t = new f(e.message);
640
- return t.stack = e.stack, t.name = e.name, t;
641
- }
642
- return new f(`${e}`);
643
- }
644
- constructor(e, t, n = "Exception") {
645
- super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
646
-
647
- Caused by ${t.stack}` : this.stack += `
648
-
649
- Caused by ${t}`);
650
- }
651
- get [Symbol.toStringTag]() {
652
- return "Exception";
653
- }
654
- }
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 {
672
- constructor(e, t, n = "ReferenceException") {
673
- super(e, t, n);
674
- }
675
- get [Symbol.toStringTag]() {
676
- return "ReferenceException";
677
- }
678
- }
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 {
688
- constructor(e, t, n = "TimeoutException") {
689
- super(e, t, n);
690
- }
691
- get [Symbol.toStringTag]() {
692
- return "TimeoutException";
693
- }
694
- }
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 {
704
- constructor(e, t, n = "ValueException") {
705
- super(e, t, n);
706
- }
707
- get [Symbol.toStringTag]() {
708
- return "ValueException";
709
- }
710
- }
711
744
  class q {
712
745
  constructor(e = !0) {
713
746
  u(this, "_preferPersistence");
@@ -857,7 +890,7 @@ class A {
857
890
  remove(e) {
858
891
  const t = this._subscribers.indexOf(e);
859
892
  if (t < 0)
860
- 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.");
861
894
  this._subscribers.splice(t, 1);
862
895
  }
863
896
  call(...e) {
@@ -867,7 +900,7 @@ class A {
867
900
  return "Subscribers";
868
901
  }
869
902
  }
870
- class x {
903
+ class g {
871
904
  constructor(e) {
872
905
  u(this, "_isPending");
873
906
  u(this, "_isFulfilled");
@@ -901,11 +934,11 @@ class x {
901
934
  return "SmartPromise";
902
935
  }
903
936
  }
904
- class O extends x {
937
+ class O extends g {
905
938
  constructor(t, n) {
906
939
  let r, s;
907
- super((i, c) => {
908
- r = i, s = c;
940
+ super((i, l) => {
941
+ r = i, s = l;
909
942
  });
910
943
  u(this, "_resolve");
911
944
  u(this, "_reject");
@@ -924,14 +957,14 @@ class O extends x {
924
957
  return "DeferredPromise";
925
958
  }
926
959
  }
927
- class $ extends x {
960
+ class $ extends g {
928
961
  constructor(e, t) {
929
962
  super((n, r) => {
930
963
  const s = (p) => {
931
- clearTimeout(g), n(p);
964
+ clearTimeout(x), n(p);
932
965
  }, i = (p) => {
933
- clearTimeout(g), r(p);
934
- }, g = setTimeout(() => i(new T("The operation has timed out.")), t);
966
+ clearTimeout(x), r(p);
967
+ }, x = setTimeout(() => i(new T("The operation has timed out.")), t);
935
968
  e(s, i);
936
969
  });
937
970
  }
@@ -967,7 +1000,7 @@ async function C(o) {
967
1000
  async function Y() {
968
1001
  return new Promise((o, e) => requestAnimationFrame(() => o()));
969
1002
  }
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 || {});
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 || {});
971
1004
  function z(o, e, t = 864e5) {
972
1005
  return Math.floor((e.getTime() - o.getTime()) / t);
973
1006
  }
@@ -1018,7 +1051,7 @@ function K(o) {
1018
1051
  e.has(t) || (e.add(t), yield t);
1019
1052
  });
1020
1053
  }
1021
- function E(o, e) {
1054
+ function j(o, e) {
1022
1055
  return new a(function* () {
1023
1056
  const t = o[Symbol.iterator](), n = e[Symbol.iterator]();
1024
1057
  for (; ; ) {
@@ -1032,14 +1065,14 @@ function E(o, e) {
1032
1065
  function L(o, e) {
1033
1066
  if (e === void 0) {
1034
1067
  let s = 0, i = 0;
1035
- for (const c of o)
1036
- s += c, i += 1;
1068
+ for (const l of o)
1069
+ s += l, i += 1;
1037
1070
  if (i === 0)
1038
1071
  throw new m("You must provide at least one value.");
1039
1072
  return s / i;
1040
1073
  }
1041
1074
  let t = 0, n = 0, r = 0;
1042
- for (const [s, i] of E(o, e)) {
1075
+ for (const [s, i] of j(o, e)) {
1043
1076
  if (i <= 0)
1044
1077
  throw new m(`The weight for the value #${r} must be greater than zero.`);
1045
1078
  t += s * i, n += i, r += 1;
@@ -1069,26 +1102,26 @@ function X(o) {
1069
1102
  }
1070
1103
  const Z = "1.5.0-rc.7";
1071
1104
  export {
1072
- w as AggregatedAsyncIterator,
1105
+ y as AggregatedAsyncIterator,
1073
1106
  d as AggregatedIterator,
1074
- y as Aggregator,
1107
+ w as Aggregator,
1075
1108
  _ as AsyncAggregator,
1076
- M as DateUnit,
1109
+ E as DateUnit,
1077
1110
  O as DeferredPromise,
1078
1111
  f as Exception,
1079
1112
  P as FatalErrorException,
1080
1113
  F as FileNotFoundException,
1081
1114
  q as JsonStorage,
1082
1115
  v as Random,
1083
- l as ReducedIterator,
1084
- I as RuntimeException,
1116
+ c as ReducedIterator,
1117
+ R as RuntimeException,
1085
1118
  h as SmartAsyncIterator,
1086
1119
  a as SmartIterator,
1087
- x as SmartPromise,
1120
+ g as SmartPromise,
1088
1121
  A as Subscribers,
1089
1122
  $ as TimedPromise,
1090
1123
  T as TimeoutException,
1091
- R as TypeException,
1124
+ M as TypeException,
1092
1125
  Z as VERSION,
1093
1126
  m as ValueException,
1094
1127
  L as average,
@@ -1105,6 +1138,6 @@ export {
1105
1138
  G as shuffle,
1106
1139
  Q as sum,
1107
1140
  K as unique,
1108
- E as zip
1141
+ j as zip
1109
1142
  };
1110
1143
  //# sourceMappingURL=core.js.map