@byloth/core 1.4.1 → 1.5.0-rc.2

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,32 +1,11 @@
1
- var y = Object.defineProperty;
2
- var g = (s, e, t) => e in s ? y(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var l = (s, e, t) => (g(s, typeof e != "symbol" ? e + "" : e, t), t);
4
- class h extends Error {
5
- static FromUnknown(e) {
6
- if (e instanceof h)
7
- return e;
8
- if (e instanceof Error) {
9
- const t = new h(e.message);
10
- return t.stack = e.stack, t.name = e.name, t;
11
- }
12
- return new h(`${e}`);
13
- }
14
- constructor(e, t, n = "Exception") {
15
- super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
16
-
17
- Caused by ${t.stack}` : this.stack += `
18
-
19
- Caused by ${t}`);
20
- }
21
- get [Symbol.toStringTag]() {
22
- return "Exception";
23
- }
24
- }
1
+ var _ = Object.defineProperty;
2
+ var g = (s, e, t) => e in s ? _(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var o = (s, e, t) => (g(s, typeof e != "symbol" ? e + "" : e, t), t);
25
4
  class u {
26
5
  constructor(e) {
27
- l(this, "_iterator");
28
- l(this, "return");
29
- l(this, "throw");
6
+ o(this, "_iterator");
7
+ o(this, "return");
8
+ o(this, "throw");
30
9
  e instanceof Function ? this._iterator = e() : Symbol.iterator in e ? this._iterator = e[Symbol.iterator]() : this._iterator = e, this._iterator.return && (this.return = (t) => this._iterator.return(t)), this._iterator.throw && (this.throw = (t) => this._iterator.throw(t));
31
10
  }
32
11
  every(e) {
@@ -135,21 +114,21 @@ class u {
135
114
  return this;
136
115
  }
137
116
  }
138
- class f {
117
+ class h {
139
118
  constructor(e) {
140
- l(this, "_elements");
119
+ o(this, "_elements");
141
120
  this._elements = new u(e);
142
121
  }
143
122
  filter(e) {
144
123
  const t = this._elements;
145
- return new f(function* () {
124
+ return new h(function* () {
146
125
  for (const [n, [r, i]] of t.enumerate())
147
126
  e(r, i, n) && (yield [r, i]);
148
127
  });
149
128
  }
150
129
  map(e) {
151
130
  const t = this._elements;
152
- return new f(function* () {
131
+ return new h(function* () {
153
132
  for (const [n, [r, i]] of t.enumerate())
154
133
  yield [r, e(r, i, n)];
155
134
  });
@@ -184,18 +163,18 @@ class f {
184
163
  return "ReducedIterator";
185
164
  }
186
165
  }
187
- class m {
166
+ class d {
188
167
  constructor(e) {
189
- l(this, "_elements");
168
+ o(this, "_elements");
190
169
  this._elements = new u(e);
191
170
  }
192
171
  every(e) {
193
172
  const t = /* @__PURE__ */ new Map();
194
173
  for (const [n, r] of this._elements) {
195
- const [i, o] = t.get(n) ?? [0, !0];
196
- o && t.set(n, [i + 1, e(n, r, i)]);
174
+ const [i, l] = t.get(n) ?? [0, !0];
175
+ l && t.set(n, [i + 1, e(n, r, i)]);
197
176
  }
198
- return new f(function* () {
177
+ return new h(function* () {
199
178
  for (const [n, [r, i]] of t)
200
179
  yield [n, i];
201
180
  });
@@ -203,56 +182,56 @@ class m {
203
182
  some(e) {
204
183
  const t = /* @__PURE__ */ new Map();
205
184
  for (const [n, r] of this._elements) {
206
- const [i, o] = t.get(n) ?? [0, !1];
207
- o || t.set(n, [i + 1, e(n, r, i)]);
185
+ const [i, l] = t.get(n) ?? [0, !1];
186
+ l || t.set(n, [i + 1, e(n, r, i)]);
208
187
  }
209
- return new f(function* () {
188
+ return new h(function* () {
210
189
  for (const [n, [r, i]] of t)
211
190
  yield [n, i];
212
191
  });
213
192
  }
214
193
  filter(e) {
215
194
  const t = this._elements;
216
- return new m(function* () {
195
+ return new d(function* () {
217
196
  const n = /* @__PURE__ */ new Map();
218
197
  for (const [r, i] of t) {
219
- const o = n.get(r) ?? 0;
220
- n.set(r, o + 1), e(r, i, o) && (yield [r, i]);
198
+ const l = n.get(r) ?? 0;
199
+ n.set(r, l + 1), e(r, i, l) && (yield [r, i]);
221
200
  }
222
201
  });
223
202
  }
224
203
  map(e) {
225
204
  const t = this._elements;
226
- return new m(function* () {
205
+ return new d(function* () {
227
206
  const n = /* @__PURE__ */ new Map();
228
207
  for (const [r, i] of t) {
229
- const o = n.get(r) ?? 0;
230
- n.set(r, o + 1), yield [r, e(r, i, o)];
208
+ const l = n.get(r) ?? 0;
209
+ n.set(r, l + 1), yield [r, e(r, i, l)];
231
210
  }
232
211
  });
233
212
  }
234
213
  reduce(e, t) {
235
214
  const n = /* @__PURE__ */ new Map();
236
215
  for (const [r, i] of this._elements) {
237
- let o, c;
216
+ let l, c;
238
217
  if (n.has(r))
239
- [o, c] = n.get(r), o += 1;
218
+ [l, c] = n.get(r), l += 1;
240
219
  else if (t !== void 0)
241
- o = 0, c = t(r);
220
+ l = 0, c = t(r);
242
221
  else {
243
222
  n.set(r, [0, i]);
244
223
  continue;
245
224
  }
246
- c = e(r, c, i, o), n.set(r, [o, c]);
225
+ c = e(r, c, i, l), n.set(r, [l, c]);
247
226
  }
248
- return new f(function* () {
249
- for (const [r, [i, o]] of n)
250
- yield [r, o];
227
+ return new h(function* () {
228
+ for (const [r, [i, l]] of n)
229
+ yield [r, l];
251
230
  });
252
231
  }
253
232
  unique() {
254
233
  const e = this._elements;
255
- return new m(function* () {
234
+ return new d(function* () {
256
235
  const t = /* @__PURE__ */ new Map();
257
236
  for (const [n, r] of e) {
258
237
  const i = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -266,7 +245,7 @@ class m {
266
245
  const n = e.get(t) ?? 0;
267
246
  e.set(t, n + 1);
268
247
  }
269
- return new f(function* () {
248
+ return new h(function* () {
270
249
  for (const [t, n] of e)
271
250
  yield [t, n];
272
251
  });
@@ -275,7 +254,7 @@ class m {
275
254
  const e = /* @__PURE__ */ new Map();
276
255
  for (const [t, n] of this._elements)
277
256
  e.has(t) || e.set(t, n);
278
- return new f(function* () {
257
+ return new h(function* () {
279
258
  for (const [t, n] of e)
280
259
  yield [t, n];
281
260
  });
@@ -284,7 +263,7 @@ class m {
284
263
  const e = /* @__PURE__ */ new Map();
285
264
  for (const [t, n] of this._elements)
286
265
  e.set(t, n);
287
- return new f(function* () {
266
+ return new h(function* () {
288
267
  for (const [t, n] of e)
289
268
  yield [t, n];
290
269
  });
@@ -329,32 +308,69 @@ class m {
329
308
  return "AggregatedIterator";
330
309
  }
331
310
  }
332
- class d {
311
+ class m {
333
312
  constructor(e) {
334
- l(this, "_elements");
313
+ o(this, "_elements");
335
314
  this._elements = new u(e);
336
315
  }
337
316
  filter(e) {
338
- return new d(this._elements.filter(e));
317
+ return new m(this._elements.filter(e));
339
318
  }
340
319
  map(e) {
341
- return new d(this._elements.map(e));
320
+ return new m(this._elements.map(e));
342
321
  }
343
322
  unique() {
344
- return new d(this._elements.unique());
323
+ return new m(this._elements.unique());
345
324
  }
346
325
  groupBy(e) {
347
- return new m(this._elements.map((t, n) => [e(t, n), t]));
326
+ return new d(this._elements.map((t, n) => [e(t, n), t]));
348
327
  }
349
328
  get [Symbol.toStringTag]() {
350
329
  return "Aggregator";
351
330
  }
352
331
  }
353
- class x {
332
+ class f extends Error {
333
+ static FromUnknown(e) {
334
+ if (e instanceof f)
335
+ return e;
336
+ if (e instanceof Error) {
337
+ const t = new f(e.message);
338
+ return t.stack = e.stack, t.name = e.name, t;
339
+ }
340
+ return new f(`${e}`);
341
+ }
342
+ constructor(e, t, n = "Exception") {
343
+ super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
344
+
345
+ Caused by ${t.stack}` : this.stack += `
346
+
347
+ Caused by ${t}`);
348
+ }
349
+ get [Symbol.toStringTag]() {
350
+ return "Exception";
351
+ }
352
+ }
353
+ class y extends f {
354
+ constructor(e, t, n = "ReferenceException") {
355
+ super(e, t, n);
356
+ }
357
+ get [Symbol.toStringTag]() {
358
+ return "ReferenceException";
359
+ }
360
+ }
361
+ class w extends f {
362
+ constructor(e, t, n = "TimeoutException") {
363
+ super(e, t, n);
364
+ }
365
+ get [Symbol.toStringTag]() {
366
+ return "TimeoutException";
367
+ }
368
+ }
369
+ class b {
354
370
  constructor(e = !0) {
355
- l(this, "_preferPersistence");
356
- l(this, "_volatile");
357
- l(this, "_persistent");
371
+ o(this, "_preferPersistence");
372
+ o(this, "_volatile");
373
+ o(this, "_persistent");
358
374
  this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
359
375
  }
360
376
  _get(e, t, n) {
@@ -488,9 +504,9 @@ class x {
488
504
  return "JsonStorage";
489
505
  }
490
506
  }
491
- class b {
507
+ class S {
492
508
  constructor() {
493
- l(this, "_subscribers");
509
+ o(this, "_subscribers");
494
510
  this._subscribers = [];
495
511
  }
496
512
  add(e) {
@@ -499,7 +515,7 @@ class b {
499
515
  remove(e) {
500
516
  const t = this._subscribers.indexOf(e);
501
517
  if (t < 0)
502
- throw new h("Unable to remove the requested subscriber. It was not found.");
518
+ throw new y("Unable to remove the requested subscriber. It was not found.");
503
519
  this._subscribers.splice(t, 1);
504
520
  }
505
521
  call(...e) {
@@ -509,23 +525,23 @@ class b {
509
525
  return "Subscribers";
510
526
  }
511
527
  }
512
- class S {
528
+ class P {
513
529
  constructor(e, t) {
514
- l(this, "_isPending");
515
- l(this, "_isFulfilled");
516
- l(this, "_isRejected");
517
- l(this, "_resolve");
518
- l(this, "_reject");
519
- l(this, "_promise");
530
+ o(this, "_isPending");
531
+ o(this, "_isFulfilled");
532
+ o(this, "_isRejected");
533
+ o(this, "_resolve");
534
+ o(this, "_reject");
535
+ o(this, "_promise");
520
536
  this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
521
- let n, r;
522
- const i = (a, _) => {
523
- n = a, r = _;
537
+ let n;
538
+ e ? n = (a) => (this._isPending = !1, this._isFulfilled = !0, e(a)) : n = (a) => (this._isPending = !1, this._isFulfilled = !0, a);
539
+ let r;
540
+ t ? r = (a) => (this._isPending = !1, this._isRejected = !0, t(a)) : r = (a) => {
541
+ throw this._isPending = !1, this._isRejected = !0, a;
524
542
  };
525
- let o;
526
- e ? o = (a) => (this._isPending = !1, this._isFulfilled = !0, e(a)) : o = (a) => (this._isPending = !1, this._isFulfilled = !0, a);
527
- let c;
528
- t ? c = (a) => (this._isPending = !1, this._isRejected = !0, t(a)) : c = (a) => (this._isPending = !1, this._isRejected = !0, a), this._promise = new Promise(i).then(o, c), this._resolve = n, this._reject = r;
543
+ const { promise: i, resolve: l, reject: c } = Promise.withResolvers();
544
+ this._promise = i.then(n, r), this._resolve = l, this._reject = c;
529
545
  }
530
546
  get isPending() {
531
547
  return this._isPending;
@@ -560,12 +576,14 @@ class S {
560
576
  }
561
577
  class k {
562
578
  constructor(e) {
563
- l(this, "_isPending");
564
- l(this, "_isFulfilled");
565
- l(this, "_isRejected");
566
- l(this, "_promise");
579
+ o(this, "_isPending");
580
+ o(this, "_isFulfilled");
581
+ o(this, "_isRejected");
582
+ o(this, "_promise");
567
583
  this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
568
- const t = (r) => (this._isPending = !1, this._isFulfilled = !0, r), n = (r) => (this._isPending = !1, this._isRejected = !0, r);
584
+ const t = (r) => (this._isPending = !1, this._isFulfilled = !0, r), n = (r) => {
585
+ throw this._isPending = !1, this._isRejected = !0, r;
586
+ };
569
587
  this._promise = new Promise(e).then(t, n);
570
588
  }
571
589
  get isPending() {
@@ -590,6 +608,42 @@ class k {
590
608
  return "SmartPromise";
591
609
  }
592
610
  }
611
+ class j {
612
+ constructor(e, t) {
613
+ o(this, "_isPending");
614
+ o(this, "_isFulfilled");
615
+ o(this, "_isRejected");
616
+ o(this, "_promise");
617
+ this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
618
+ const n = (c) => (this._isPending = !1, this._isFulfilled = !0, c), r = (c) => {
619
+ throw this._isPending = !1, this._isRejected = !0, c;
620
+ }, i = new Promise(e), l = new Promise((c, a) => setTimeout(() => {
621
+ a(new w("The operation has timed out."));
622
+ }, t));
623
+ this._promise = Promise.race([i, l]).then(n, r);
624
+ }
625
+ get isPending() {
626
+ return this._isPending;
627
+ }
628
+ get isFulfilled() {
629
+ return this._isFulfilled;
630
+ }
631
+ get isRejected() {
632
+ return this._isRejected;
633
+ }
634
+ then(e, t) {
635
+ return this._promise.then(e, t);
636
+ }
637
+ catch(e) {
638
+ return this._promise.catch(e);
639
+ }
640
+ finally(e) {
641
+ return this._promise.finally(e);
642
+ }
643
+ get [Symbol.toStringTag]() {
644
+ return "TimedPromise";
645
+ }
646
+ }
593
647
  class M {
594
648
  static Boolean(e = 0.5) {
595
649
  return Math.random() < e;
@@ -607,17 +661,17 @@ class M {
607
661
  constructor() {
608
662
  }
609
663
  }
610
- async function P(s) {
664
+ async function R(s) {
611
665
  return new Promise((e, t) => setTimeout(e, s));
612
666
  }
613
- async function j() {
667
+ async function T() {
614
668
  return new Promise((s, e) => requestAnimationFrame(() => s()));
615
669
  }
616
- var w = /* @__PURE__ */ ((s) => (s[s.Second = 1e3] = "Second", s[s.Minute = 6e4] = "Minute", s[s.Hour = 36e5] = "Hour", s[s.Day = 864e5] = "Day", s[s.Week = 6048e5] = "Week", s[s.Month = 2592e6] = "Month", s[s.Year = 31536e6] = "Year", s))(w || {});
617
- function T(s, e, t = 864e5) {
670
+ var p = /* @__PURE__ */ ((s) => (s[s.Second = 1e3] = "Second", s[s.Minute = 6e4] = "Minute", s[s.Hour = 36e5] = "Hour", s[s.Day = 864e5] = "Day", s[s.Week = 6048e5] = "Week", s[s.Month = 2592e6] = "Month", s[s.Year = 31536e6] = "Year", s))(p || {});
671
+ function F(s, e, t = 864e5) {
618
672
  return Math.floor((e.getTime() - s.getTime()) / t);
619
673
  }
620
- function R(s, e, t = 864e5) {
674
+ function I(s, e, t = 864e5) {
621
675
  return new u(function* () {
622
676
  const n = e.getTime();
623
677
  let r = s.getTime();
@@ -625,16 +679,16 @@ function R(s, e, t = 864e5) {
625
679
  yield new Date(r), r += t;
626
680
  });
627
681
  }
628
- function F(s, e = 864e5) {
682
+ function E(s, e = 864e5) {
629
683
  return new Date(Math.floor(s.getTime() / e) * e);
630
684
  }
631
- async function I(s, e = "text/javascript") {
685
+ async function A(s, e = "text/javascript") {
632
686
  return new Promise((t, n) => {
633
687
  const r = document.createElement("script");
634
688
  r.async = !0, r.defer = !0, r.src = s, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
635
689
  });
636
690
  }
637
- function A(s) {
691
+ function q(s) {
638
692
  if (Array.isArray(s))
639
693
  return s.length;
640
694
  let e = 0;
@@ -642,14 +696,14 @@ function A(s) {
642
696
  e += 1;
643
697
  return e;
644
698
  }
645
- function E(s, e, t = 1) {
699
+ function C(s, e, t = 1) {
646
700
  return new u(function* () {
647
701
  e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
648
702
  for (let n = s; n < e; n += t)
649
703
  yield n;
650
704
  });
651
705
  }
652
- function q(s) {
706
+ function O(s) {
653
707
  const e = Array.from(s);
654
708
  for (let t = e.length - 1; t > 0; t -= 1) {
655
709
  const n = Math.floor(Math.random() * (t + 1));
@@ -657,7 +711,7 @@ function q(s) {
657
711
  }
658
712
  return e;
659
713
  }
660
- function C(s) {
714
+ function $(s) {
661
715
  return new u(function* () {
662
716
  const e = /* @__PURE__ */ new Set();
663
717
  for (const t of s)
@@ -675,11 +729,11 @@ function v(s, e) {
675
729
  }
676
730
  });
677
731
  }
678
- function O(s, e) {
732
+ function J(s, e) {
679
733
  if (e === void 0) {
680
734
  let r = 0, i = 0;
681
- for (const o of s)
682
- r += o, i += 1;
735
+ for (const l of s)
736
+ r += l, i += 1;
683
737
  return r / i;
684
738
  }
685
739
  let t = 0, n = 0;
@@ -687,7 +741,7 @@ function O(s, e) {
687
741
  t += r * i, n += i;
688
742
  return t / n;
689
743
  }
690
- function $(s) {
744
+ function V(s) {
691
745
  let e = 0;
692
746
  for (let t = 0; t < s.length; t += 1) {
693
747
  const n = s.charCodeAt(t);
@@ -695,43 +749,46 @@ function $(s) {
695
749
  }
696
750
  return e;
697
751
  }
698
- function J(s) {
752
+ function z(s) {
699
753
  let e = 0;
700
754
  for (const t of s)
701
755
  e += t;
702
756
  return e;
703
757
  }
704
- function V(s) {
758
+ function B(s) {
705
759
  return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
706
760
  }
707
- const z = "1.4.1";
761
+ const H = "1.5.0-rc.2";
708
762
  export {
709
- m as AggregatedIterator,
710
- d as Aggregator,
711
- w as DateUnit,
712
- S as DeferredPromise,
713
- h as Exception,
714
- x as JsonStorage,
763
+ d as AggregatedIterator,
764
+ m as Aggregator,
765
+ p as DateUnit,
766
+ P as DeferredPromise,
767
+ f as Exception,
768
+ b as JsonStorage,
715
769
  M as Random,
716
- f as ReducedIterator,
770
+ h as ReducedIterator,
771
+ y as ReferenceException,
717
772
  u as SmartIterator,
718
773
  k as SmartPromise,
719
- b as Subscribers,
720
- z as VERSION,
721
- O as average,
722
- V as capitalize,
723
- A as count,
724
- T as dateDifference,
725
- R as dateRange,
726
- F as dateRound,
727
- P as delay,
728
- $ as hash,
729
- I as loadScript,
730
- j as nextAnimationFrame,
731
- E as range,
732
- q as shuffle,
733
- J as sum,
734
- C as unique,
774
+ S as Subscribers,
775
+ j as TimedPromise,
776
+ w as TimeoutException,
777
+ H as VERSION,
778
+ J as average,
779
+ B as capitalize,
780
+ q as count,
781
+ F as dateDifference,
782
+ I as dateRange,
783
+ E as dateRound,
784
+ R as delay,
785
+ V as hash,
786
+ A as loadScript,
787
+ T as nextAnimationFrame,
788
+ C as range,
789
+ O as shuffle,
790
+ z as sum,
791
+ $ as unique,
735
792
  v as zip
736
793
  };
737
794
  //# sourceMappingURL=core.js.map