@byloth/core 1.3.0-rc.2 → 1.3.1

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,15 +1,15 @@
1
- var d = Object.defineProperty;
2
- var _ = (s, e, t) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var u = (s, e, t) => (_(s, typeof e != "symbol" ? e + "" : e, t), t);
4
- class h extends Error {
1
+ var w = Object.defineProperty;
2
+ var y = (s, e, t) => e in s ? w(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var u = (s, e, t) => (y(s, typeof e != "symbol" ? e + "" : e, t), t);
4
+ class f extends Error {
5
5
  static FromUnknown(e) {
6
- if (e instanceof h)
6
+ if (e instanceof f)
7
7
  return e;
8
8
  if (e instanceof Error) {
9
- const t = new h(e.message);
9
+ const t = new f(e.message);
10
10
  return t.stack = e.stack, t.name = e.name, t;
11
11
  }
12
- return new h(`${e}`);
12
+ return new f(`${e}`);
13
13
  }
14
14
  constructor(e, t, r = "Exception") {
15
15
  super(e), this.cause = t, this.name = r, t && (t instanceof Error ? this.stack += `
@@ -19,7 +19,7 @@ Caused by ${t.stack}` : this.stack += `
19
19
  Caused by ${t}`);
20
20
  }
21
21
  }
22
- class c {
22
+ class l {
23
23
  constructor(e) {
24
24
  u(this, "_iterator");
25
25
  u(this, "return");
@@ -50,7 +50,7 @@ class c {
50
50
  }
51
51
  filter(e) {
52
52
  const t = this._iterator;
53
- return new c(function* () {
53
+ return new l(function* () {
54
54
  let r = 0;
55
55
  for (; ; ) {
56
56
  const n = t.next();
@@ -62,7 +62,7 @@ class c {
62
62
  }
63
63
  map(e) {
64
64
  const t = this._iterator;
65
- return new c(function* () {
65
+ return new l(function* () {
66
66
  let r = 0;
67
67
  for (; ; ) {
68
68
  const n = t.next();
@@ -75,16 +75,16 @@ class c {
75
75
  reduce(e, t) {
76
76
  let r = 0, n = t;
77
77
  if (n === void 0) {
78
- const o = this._iterator.next();
79
- if (o.done)
78
+ const i = this._iterator.next();
79
+ if (i.done)
80
80
  throw new TypeError("Reduce of empty iterator with no initial value");
81
- n = o.value, r += 1;
81
+ n = i.value, r += 1;
82
82
  }
83
83
  for (; ; ) {
84
- const o = this._iterator.next();
85
- if (o.done)
84
+ const i = this._iterator.next();
85
+ if (i.done)
86
86
  return n;
87
- n = e(n, o.value, r), r += 1;
87
+ n = e(n, i.value, r), r += 1;
88
88
  }
89
89
  }
90
90
  enumerate() {
@@ -92,7 +92,7 @@ class c {
92
92
  }
93
93
  unique() {
94
94
  const e = this._iterator;
95
- return new c(function* () {
95
+ return new l(function* () {
96
96
  const t = /* @__PURE__ */ new Set();
97
97
  for (; ; ) {
98
98
  const r = e.next();
@@ -129,23 +129,23 @@ class c {
129
129
  return this;
130
130
  }
131
131
  }
132
- class l {
132
+ class h {
133
133
  constructor(e) {
134
134
  u(this, "_elements");
135
- this._elements = new c(e);
135
+ this._elements = new l(e);
136
136
  }
137
137
  filter(e) {
138
138
  const t = this._elements;
139
- return new l(function* () {
140
- for (const [r, [n, o]] of t.enumerate())
141
- e(n, o, r) && (yield [n, o]);
139
+ return new h(function* () {
140
+ for (const [r, [n, i]] of t.enumerate())
141
+ e(n, i, r) && (yield [n, i]);
142
142
  });
143
143
  }
144
144
  map(e) {
145
145
  const t = this._elements;
146
- return new l(function* () {
147
- for (const [r, [n, o]] of t.enumerate())
148
- yield [n, e(n, o, r)];
146
+ return new h(function* () {
147
+ for (const [r, [n, i]] of t.enumerate())
148
+ yield [n, e(n, i, r)];
149
149
  });
150
150
  }
151
151
  toArray() {
@@ -158,79 +158,79 @@ class l {
158
158
  return Object.fromEntries(this._elements.toArray());
159
159
  }
160
160
  }
161
- class f {
161
+ class d {
162
162
  constructor(e) {
163
163
  u(this, "_elements");
164
- this._elements = new c(e);
164
+ this._elements = new l(e);
165
165
  }
166
166
  every(e) {
167
167
  const t = /* @__PURE__ */ new Map();
168
168
  for (const [r, n] of this._elements) {
169
- const [o, i] = t.get(r) ?? [0, !0];
170
- i && t.set(r, [o + 1, e(r, n, o)]);
169
+ const [i, o] = t.get(r) ?? [0, !0];
170
+ o && t.set(r, [i + 1, e(r, n, i)]);
171
171
  }
172
- return new l(function* () {
173
- for (const [r, [n, o]] of t)
174
- yield [r, o];
172
+ return new h(function* () {
173
+ for (const [r, [n, i]] of t)
174
+ yield [r, i];
175
175
  });
176
176
  }
177
177
  some(e) {
178
178
  const t = /* @__PURE__ */ new Map();
179
179
  for (const [r, n] of this._elements) {
180
- const [o, i] = t.get(r) ?? [0, !1];
181
- i || t.set(r, [o + 1, e(r, n, o)]);
180
+ const [i, o] = t.get(r) ?? [0, !1];
181
+ o || t.set(r, [i + 1, e(r, n, i)]);
182
182
  }
183
- return new l(function* () {
184
- for (const [r, [n, o]] of t)
185
- yield [r, o];
183
+ return new h(function* () {
184
+ for (const [r, [n, i]] of t)
185
+ yield [r, i];
186
186
  });
187
187
  }
188
188
  filter(e) {
189
189
  const t = this._elements;
190
- return new f(function* () {
190
+ return new d(function* () {
191
191
  const r = /* @__PURE__ */ new Map();
192
- for (const [n, o] of t) {
193
- const i = r.get(n) ?? 0;
194
- r.set(n, i + 1), e(n, o, i) && (yield [n, o]);
192
+ for (const [n, i] of t) {
193
+ const o = r.get(n) ?? 0;
194
+ r.set(n, o + 1), e(n, i, o) && (yield [n, i]);
195
195
  }
196
196
  });
197
197
  }
198
198
  map(e) {
199
199
  const t = this._elements;
200
- return new f(function* () {
200
+ return new d(function* () {
201
201
  const r = /* @__PURE__ */ new Map();
202
- for (const [n, o] of t) {
203
- const i = r.get(n) ?? 0;
204
- r.set(n, i + 1), yield [n, e(n, o, i)];
202
+ for (const [n, i] of t) {
203
+ const o = r.get(n) ?? 0;
204
+ r.set(n, o + 1), yield [n, e(n, i, o)];
205
205
  }
206
206
  });
207
207
  }
208
208
  reduce(e, t) {
209
209
  const r = /* @__PURE__ */ new Map();
210
- for (const [n, o] of this._elements) {
211
- let i, a;
210
+ for (const [n, i] of this._elements) {
211
+ let o, c;
212
212
  if (r.has(n))
213
- [i, a] = r.get(n), i += 1;
213
+ [o, c] = r.get(n), o += 1;
214
214
  else if (t !== void 0)
215
- i = 0, a = t;
215
+ o = 0, c = t;
216
216
  else {
217
- r.set(n, [0, o]);
217
+ r.set(n, [0, i]);
218
218
  continue;
219
219
  }
220
- a = e(n, a, o, i), r.set(n, [i, a]);
220
+ c = e(n, c, i, o), r.set(n, [o, c]);
221
221
  }
222
- return new l(function* () {
223
- for (const [n, [o, i]] of r)
224
- yield [n, i];
222
+ return new h(function* () {
223
+ for (const [n, [i, o]] of r)
224
+ yield [n, o];
225
225
  });
226
226
  }
227
227
  unique() {
228
228
  const e = this._elements;
229
- return new f(function* () {
229
+ return new d(function* () {
230
230
  const t = /* @__PURE__ */ new Map();
231
231
  for (const [r, n] of e) {
232
- const o = t.get(r) ?? /* @__PURE__ */ new Set();
233
- o.has(n) || (o.add(n), t.set(r, o), yield [r, n]);
232
+ const i = t.get(r) ?? /* @__PURE__ */ new Set();
233
+ i.has(n) || (i.add(n), t.set(r, i), yield [r, n]);
234
234
  }
235
235
  });
236
236
  }
@@ -240,7 +240,7 @@ class f {
240
240
  const r = e.get(t) ?? 0;
241
241
  e.set(t, r + 1);
242
242
  }
243
- return new l(function* () {
243
+ return new h(function* () {
244
244
  for (const [t, r] of e)
245
245
  yield [t, r];
246
246
  });
@@ -265,54 +265,22 @@ class f {
265
265
  return e;
266
266
  }
267
267
  }
268
- class m {
268
+ class _ {
269
269
  constructor(e) {
270
270
  u(this, "_elements");
271
- this._elements = new c(e);
271
+ this._elements = new l(e);
272
272
  }
273
273
  filter(e) {
274
- return new m(this._elements.filter(e));
274
+ return new _(this._elements.filter(e));
275
275
  }
276
276
  map(e) {
277
- return new m(this._elements.map(e));
277
+ return new _(this._elements.map(e));
278
278
  }
279
279
  unique() {
280
- return new m(this._elements.unique());
280
+ return new _(this._elements.unique());
281
281
  }
282
282
  byKey(e) {
283
- return new f(this._elements.map((t, r) => [e(t, r), t]));
284
- }
285
- }
286
- class p {
287
- constructor(e, t) {
288
- u(this, "_resolve");
289
- u(this, "_reject");
290
- u(this, "_promise");
291
- let r, n;
292
- this._promise = new Promise((o, i) => {
293
- r = o, n = i;
294
- }).then(e, t), this._resolve = r, this._reject = n;
295
- }
296
- get resolve() {
297
- return this._resolve;
298
- }
299
- get reject() {
300
- return this._reject;
301
- }
302
- then(e, t) {
303
- return this._promise.then(e, t);
304
- }
305
- catch(e) {
306
- return this._promise.catch(e);
307
- }
308
- finally(e) {
309
- return this._promise.finally(e);
310
- }
311
- watch(e) {
312
- return e.then(this.resolve, this.reject), this;
313
- }
314
- get [Symbol.toStringTag]() {
315
- return "DeferredPromise";
283
+ return new d(this._elements.map((t, r) => [e(t, r), t]));
316
284
  }
317
285
  }
318
286
  class x {
@@ -461,14 +429,95 @@ class b {
461
429
  remove(e) {
462
430
  const t = this._subscribers.indexOf(e);
463
431
  if (t < 0)
464
- throw new h("Unable to remove the requested subscriber. It was not found.");
432
+ throw new f("Unable to remove the requested subscriber. It was not found.");
465
433
  this._subscribers.splice(t, 1);
466
434
  }
467
435
  call(...e) {
468
436
  return this._subscribers.slice().map((t) => t(...e));
469
437
  }
470
438
  }
471
- class g {
439
+ class k {
440
+ constructor(e, t) {
441
+ u(this, "_isPending");
442
+ u(this, "_isFulfilled");
443
+ u(this, "_isRejected");
444
+ u(this, "_resolve");
445
+ u(this, "_reject");
446
+ u(this, "_promise");
447
+ this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
448
+ let r, n;
449
+ const i = (a, m) => {
450
+ r = a, n = m;
451
+ };
452
+ let o;
453
+ e ? o = (a) => (this._isPending = !1, this._isFulfilled = !0, e(a)) : o = (a) => (this._isPending = !1, this._isFulfilled = !0, a);
454
+ let c;
455
+ 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 = r, this._reject = n;
456
+ }
457
+ get isPending() {
458
+ return this._isPending;
459
+ }
460
+ get isFulfilled() {
461
+ return this._isFulfilled;
462
+ }
463
+ get isRejected() {
464
+ return this._isRejected;
465
+ }
466
+ get resolve() {
467
+ return this._resolve;
468
+ }
469
+ get reject() {
470
+ return this._reject;
471
+ }
472
+ then(e, t) {
473
+ return this._promise.then(e, t);
474
+ }
475
+ catch(e) {
476
+ return this._promise.catch(e);
477
+ }
478
+ finally(e) {
479
+ return this._promise.finally(e);
480
+ }
481
+ watch(e) {
482
+ return e.then(this.resolve, this.reject), this;
483
+ }
484
+ get [Symbol.toStringTag]() {
485
+ return "DeferredPromise";
486
+ }
487
+ }
488
+ class M {
489
+ constructor(e) {
490
+ u(this, "_isPending");
491
+ u(this, "_isFulfilled");
492
+ u(this, "_isRejected");
493
+ u(this, "_promise");
494
+ this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
495
+ const t = (n) => (this._isPending = !1, this._isFulfilled = !0, n), r = (n) => (this._isPending = !1, this._isRejected = !0, n);
496
+ this._promise = new Promise(e).then(t, r);
497
+ }
498
+ get isPending() {
499
+ return this._isPending;
500
+ }
501
+ get isFulfilled() {
502
+ return this._isFulfilled;
503
+ }
504
+ get isRejected() {
505
+ return this._isRejected;
506
+ }
507
+ then(e, t) {
508
+ return this._promise.then(e, t);
509
+ }
510
+ catch(e) {
511
+ return this._promise.catch(e);
512
+ }
513
+ finally(e) {
514
+ return this._promise.finally(e);
515
+ }
516
+ get [Symbol.toStringTag]() {
517
+ return "SmartPromise";
518
+ }
519
+ }
520
+ class P {
472
521
  static Boolean(e = 0.5) {
473
522
  return Math.random() < e;
474
523
  }
@@ -485,18 +534,18 @@ class g {
485
534
  constructor() {
486
535
  }
487
536
  }
488
- async function k(s) {
537
+ async function j(s) {
489
538
  return new Promise((e, t) => setTimeout(e, s));
490
539
  }
491
- async function M() {
540
+ async function S() {
492
541
  return new Promise((s, e) => requestAnimationFrame(() => s()));
493
542
  }
494
- 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 || {});
495
- function S(s, e, t = 864e5) {
543
+ var v = /* @__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))(v || {});
544
+ function R(s, e, t = 864e5) {
496
545
  return Math.floor((e.getTime() - s.getTime()) / t);
497
546
  }
498
- function j(s, e, t = 864e5) {
499
- return new c(function* () {
547
+ function F(s, e, t = 864e5) {
548
+ return new l(function* () {
500
549
  const r = e.getTime();
501
550
  let n = s.getTime();
502
551
  for (; n < r; )
@@ -506,13 +555,13 @@ function j(s, e, t = 864e5) {
506
555
  function I(s, e = 864e5) {
507
556
  return new Date(Math.floor(s.getTime() / e) * e);
508
557
  }
509
- async function A(s, e = "text/javascript") {
558
+ async function T(s, e = "text/javascript") {
510
559
  return new Promise((t, r) => {
511
560
  const n = document.createElement("script");
512
561
  n.async = !0, n.defer = !0, n.src = s, n.type = e, n.onload = () => t(), n.onerror = () => r(), document.body.appendChild(n);
513
562
  });
514
563
  }
515
- function T(s) {
564
+ function A(s) {
516
565
  if (Array.isArray(s))
517
566
  return s.length;
518
567
  let e = 0;
@@ -520,14 +569,14 @@ function T(s) {
520
569
  e += 1;
521
570
  return e;
522
571
  }
523
- function P(s, e, t = 1) {
524
- return new c(function* () {
572
+ function q(s, e, t = 1) {
573
+ return new l(function* () {
525
574
  e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
526
575
  for (let r = s; r < e; r += t)
527
576
  yield r;
528
577
  });
529
578
  }
530
- function q(s) {
579
+ function C(s) {
531
580
  const e = Array.from(s);
532
581
  for (let t = e.length - 1; t > 0; t -= 1) {
533
582
  const r = Math.floor(Math.random() * (t + 1));
@@ -535,37 +584,37 @@ function q(s) {
535
584
  }
536
585
  return e;
537
586
  }
538
- function C(s) {
539
- return new c(function* () {
587
+ function E(s) {
588
+ return new l(function* () {
540
589
  const e = /* @__PURE__ */ new Set();
541
590
  for (const t of s)
542
591
  e.has(t) || (e.add(t), yield t);
543
592
  });
544
593
  }
545
- function y(s, e) {
546
- return new c(function* () {
594
+ function p(s, e) {
595
+ return new l(function* () {
547
596
  const t = s[Symbol.iterator](), r = e[Symbol.iterator]();
548
597
  for (; ; ) {
549
- const n = t.next(), o = r.next();
550
- if (n.done || o.done)
598
+ const n = t.next(), i = r.next();
599
+ if (n.done || i.done)
551
600
  break;
552
- yield [n.value, o.value];
601
+ yield [n.value, i.value];
553
602
  }
554
603
  });
555
604
  }
556
- function E(s, e) {
605
+ function O(s, e) {
557
606
  if (e === void 0) {
558
- let n = 0, o = 0;
559
- for (const i of s)
560
- n += i, o += 1;
561
- return n / o;
607
+ let n = 0, i = 0;
608
+ for (const o of s)
609
+ n += o, i += 1;
610
+ return n / i;
562
611
  }
563
612
  let t = 0, r = 0;
564
- for (const [n, o] of y(s, e))
565
- t += n * o, r += o;
613
+ for (const [n, i] of p(s, e))
614
+ t += n * i, r += i;
566
615
  return t / r;
567
616
  }
568
- function O(s) {
617
+ function $(s) {
569
618
  let e = 0;
570
619
  for (let t = 0; t < s.length; t += 1) {
571
620
  const r = s.charCodeAt(t);
@@ -573,42 +622,43 @@ function O(s) {
573
622
  }
574
623
  return e;
575
624
  }
576
- function $(s) {
625
+ function J(s) {
577
626
  let e = 0;
578
627
  for (const t of s)
579
628
  e += t;
580
629
  return e;
581
630
  }
582
- function R(s) {
631
+ function V(s) {
583
632
  return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
584
633
  }
585
- const F = "1.3.0-rc.2";
634
+ const z = "1.3.1";
586
635
  export {
587
- f as AggregatedIterator,
588
- m as Aggregator,
589
- w as DateUnit,
590
- p as DeferredPromise,
591
- h as Exception,
636
+ d as AggregatedIterator,
637
+ _ as Aggregator,
638
+ v as DateUnit,
639
+ k as DeferredPromise,
640
+ f as Exception,
592
641
  x as JsonStorage,
593
- g as Random,
594
- l as ReducedIterator,
595
- c as SmartIterator,
642
+ P as Random,
643
+ h as ReducedIterator,
644
+ l as SmartIterator,
645
+ M as SmartPromise,
596
646
  b as Subscribers,
597
- F as VERSION,
598
- E as average,
599
- R as capitalize,
600
- T as count,
601
- S as dateDifference,
602
- j as dateRange,
647
+ z as VERSION,
648
+ O as average,
649
+ V as capitalize,
650
+ A as count,
651
+ R as dateDifference,
652
+ F as dateRange,
603
653
  I as dateRound,
604
- k as delay,
605
- O as hash,
606
- A as loadScript,
607
- M as nextAnimationFrame,
608
- P as range,
609
- q as shuffle,
610
- $ as sum,
611
- C as unique,
612
- y as zip
654
+ j as delay,
655
+ $ as hash,
656
+ T as loadScript,
657
+ S as nextAnimationFrame,
658
+ q as range,
659
+ C as shuffle,
660
+ J as sum,
661
+ E as unique,
662
+ p as zip
613
663
  };
614
664
  //# sourceMappingURL=core.js.map