@byloth/core 1.3.0-rc.1 → 1.3.0
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 +117 -117
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +1 -1
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +4 -2
- package/src/types.ts +3 -0
- package/src/models/aggregators/_index.old.ts +0 -384
package/dist/core.js
CHANGED
|
@@ -11,8 +11,8 @@ class h extends Error {
|
|
|
11
11
|
}
|
|
12
12
|
return new h(`${e}`);
|
|
13
13
|
}
|
|
14
|
-
constructor(e, t,
|
|
15
|
-
super(e), this.cause = t, this.name =
|
|
14
|
+
constructor(e, t, n = "Exception") {
|
|
15
|
+
super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
|
|
16
16
|
|
|
17
17
|
Caused by ${t.stack}` : this.stack += `
|
|
18
18
|
|
|
@@ -29,10 +29,10 @@ class c {
|
|
|
29
29
|
every(e) {
|
|
30
30
|
let t = 0;
|
|
31
31
|
for (; ; ) {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
32
|
+
const n = this._iterator.next();
|
|
33
|
+
if (n.done)
|
|
34
34
|
return !0;
|
|
35
|
-
if (!e(
|
|
35
|
+
if (!e(n.value, t))
|
|
36
36
|
return !1;
|
|
37
37
|
t += 1;
|
|
38
38
|
}
|
|
@@ -40,10 +40,10 @@ class c {
|
|
|
40
40
|
some(e) {
|
|
41
41
|
let t = 0;
|
|
42
42
|
for (; ; ) {
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
43
|
+
const n = this._iterator.next();
|
|
44
|
+
if (n.done)
|
|
45
45
|
return !1;
|
|
46
|
-
if (e(
|
|
46
|
+
if (e(n.value, t))
|
|
47
47
|
return !0;
|
|
48
48
|
t += 1;
|
|
49
49
|
}
|
|
@@ -51,40 +51,40 @@ class c {
|
|
|
51
51
|
filter(e) {
|
|
52
52
|
const t = this._iterator;
|
|
53
53
|
return new c(function* () {
|
|
54
|
-
let
|
|
54
|
+
let n = 0;
|
|
55
55
|
for (; ; ) {
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
59
|
-
e(
|
|
56
|
+
const r = t.next();
|
|
57
|
+
if (r.done)
|
|
58
|
+
return r.value;
|
|
59
|
+
e(r.value, n) && (yield r.value), n += 1;
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
map(e) {
|
|
64
64
|
const t = this._iterator;
|
|
65
65
|
return new c(function* () {
|
|
66
|
-
let
|
|
66
|
+
let n = 0;
|
|
67
67
|
for (; ; ) {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
return
|
|
71
|
-
yield e(
|
|
68
|
+
const r = t.next();
|
|
69
|
+
if (r.done)
|
|
70
|
+
return r.value;
|
|
71
|
+
yield e(r.value, n), n += 1;
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
reduce(e, t) {
|
|
76
|
-
let
|
|
77
|
-
if (
|
|
76
|
+
let n = 0, r = t;
|
|
77
|
+
if (r === void 0) {
|
|
78
78
|
const o = this._iterator.next();
|
|
79
79
|
if (o.done)
|
|
80
80
|
throw new TypeError("Reduce of empty iterator with no initial value");
|
|
81
|
-
|
|
81
|
+
r = o.value, n += 1;
|
|
82
82
|
}
|
|
83
83
|
for (; ; ) {
|
|
84
84
|
const o = this._iterator.next();
|
|
85
85
|
if (o.done)
|
|
86
|
-
return
|
|
87
|
-
|
|
86
|
+
return r;
|
|
87
|
+
r = e(r, o.value, n), n += 1;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
enumerate() {
|
|
@@ -95,10 +95,10 @@ class c {
|
|
|
95
95
|
return new c(function* () {
|
|
96
96
|
const t = /* @__PURE__ */ new Set();
|
|
97
97
|
for (; ; ) {
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
101
|
-
t.has(
|
|
98
|
+
const n = e.next();
|
|
99
|
+
if (n.done)
|
|
100
|
+
return n.value;
|
|
101
|
+
t.has(n.value) || (t.add(n.value), yield n.value);
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
}
|
|
@@ -113,10 +113,10 @@ class c {
|
|
|
113
113
|
forEach(e) {
|
|
114
114
|
let t = 0;
|
|
115
115
|
for (; ; ) {
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
116
|
+
const n = this._iterator.next();
|
|
117
|
+
if (n.done)
|
|
118
118
|
return;
|
|
119
|
-
e(
|
|
119
|
+
e(n.value, t), t += 1;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
next(...e) {
|
|
@@ -137,15 +137,15 @@ class l {
|
|
|
137
137
|
filter(e) {
|
|
138
138
|
const t = this._elements;
|
|
139
139
|
return new l(function* () {
|
|
140
|
-
for (const [
|
|
141
|
-
e(
|
|
140
|
+
for (const [n, [r, o]] of t.enumerate())
|
|
141
|
+
e(r, o, n) && (yield [r, o]);
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
map(e) {
|
|
145
145
|
const t = this._elements;
|
|
146
146
|
return new l(function* () {
|
|
147
|
-
for (const [
|
|
148
|
-
yield [
|
|
147
|
+
for (const [n, [r, o]] of t.enumerate())
|
|
148
|
+
yield [r, e(r, o, n)];
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
toArray() {
|
|
@@ -165,84 +165,84 @@ class f {
|
|
|
165
165
|
}
|
|
166
166
|
every(e) {
|
|
167
167
|
const t = /* @__PURE__ */ new Map();
|
|
168
|
-
for (const [
|
|
169
|
-
const [o, i] = t.get(
|
|
170
|
-
i && t.set(
|
|
168
|
+
for (const [n, r] of this._elements) {
|
|
169
|
+
const [o, i] = t.get(n) ?? [0, !0];
|
|
170
|
+
i && t.set(n, [o + 1, e(n, r, o)]);
|
|
171
171
|
}
|
|
172
172
|
return new l(function* () {
|
|
173
|
-
for (const [
|
|
174
|
-
yield [
|
|
173
|
+
for (const [n, [r, o]] of t)
|
|
174
|
+
yield [n, o];
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
some(e) {
|
|
178
178
|
const t = /* @__PURE__ */ new Map();
|
|
179
|
-
for (const [
|
|
180
|
-
const [o, i] = t.get(
|
|
181
|
-
i || t.set(
|
|
179
|
+
for (const [n, r] of this._elements) {
|
|
180
|
+
const [o, i] = t.get(n) ?? [0, !1];
|
|
181
|
+
i || t.set(n, [o + 1, e(n, r, o)]);
|
|
182
182
|
}
|
|
183
183
|
return new l(function* () {
|
|
184
|
-
for (const [
|
|
185
|
-
yield [
|
|
184
|
+
for (const [n, [r, o]] of t)
|
|
185
|
+
yield [n, o];
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
filter(e) {
|
|
189
189
|
const t = this._elements;
|
|
190
190
|
return new f(function* () {
|
|
191
|
-
const
|
|
192
|
-
for (const [
|
|
193
|
-
const i =
|
|
194
|
-
|
|
191
|
+
const n = /* @__PURE__ */ new Map();
|
|
192
|
+
for (const [r, o] of t) {
|
|
193
|
+
const i = n.get(r) ?? 0;
|
|
194
|
+
n.set(r, i + 1), e(r, o, i) && (yield [r, o]);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
map(e) {
|
|
199
199
|
const t = this._elements;
|
|
200
200
|
return new f(function* () {
|
|
201
|
-
const
|
|
202
|
-
for (const [
|
|
203
|
-
const i =
|
|
204
|
-
|
|
201
|
+
const n = /* @__PURE__ */ new Map();
|
|
202
|
+
for (const [r, o] of t) {
|
|
203
|
+
const i = n.get(r) ?? 0;
|
|
204
|
+
n.set(r, i + 1), yield [r, e(r, o, i)];
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
reduce(e, t) {
|
|
209
|
-
const
|
|
210
|
-
for (const [
|
|
209
|
+
const n = /* @__PURE__ */ new Map();
|
|
210
|
+
for (const [r, o] of this._elements) {
|
|
211
211
|
let i, a;
|
|
212
|
-
if (
|
|
213
|
-
[i, a] =
|
|
212
|
+
if (n.has(r))
|
|
213
|
+
[i, a] = n.get(r), i += 1;
|
|
214
214
|
else if (t !== void 0)
|
|
215
215
|
i = 0, a = t;
|
|
216
216
|
else {
|
|
217
|
-
|
|
217
|
+
n.set(r, [0, o]);
|
|
218
218
|
continue;
|
|
219
219
|
}
|
|
220
|
-
a = e(
|
|
220
|
+
a = e(r, a, o, i), n.set(r, [i, a]);
|
|
221
221
|
}
|
|
222
222
|
return new l(function* () {
|
|
223
|
-
for (const [
|
|
224
|
-
yield [
|
|
223
|
+
for (const [r, [o, i]] of n)
|
|
224
|
+
yield [r, i];
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
unique() {
|
|
228
228
|
const e = this._elements;
|
|
229
229
|
return new f(function* () {
|
|
230
230
|
const t = /* @__PURE__ */ new Map();
|
|
231
|
-
for (const [
|
|
232
|
-
const o = t.get(
|
|
233
|
-
o.has(
|
|
231
|
+
for (const [n, r] of e) {
|
|
232
|
+
const o = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
233
|
+
o.has(r) || (o.add(r), t.set(n, o), yield [n, r]);
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
count() {
|
|
238
238
|
const e = /* @__PURE__ */ new Map();
|
|
239
239
|
for (const [t] of this._elements) {
|
|
240
|
-
const
|
|
241
|
-
e.set(t,
|
|
240
|
+
const n = e.get(t) ?? 0;
|
|
241
|
+
e.set(t, n + 1);
|
|
242
242
|
}
|
|
243
243
|
return new l(function* () {
|
|
244
|
-
for (const [t,
|
|
245
|
-
yield [t,
|
|
244
|
+
for (const [t, n] of e)
|
|
245
|
+
yield [t, n];
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
248
|
toArray() {
|
|
@@ -250,17 +250,17 @@ class f {
|
|
|
250
250
|
}
|
|
251
251
|
toMap() {
|
|
252
252
|
const e = /* @__PURE__ */ new Map();
|
|
253
|
-
for (const [t,
|
|
254
|
-
const
|
|
255
|
-
|
|
253
|
+
for (const [t, n] of this._elements) {
|
|
254
|
+
const r = e.get(t) ?? [];
|
|
255
|
+
r.push(n), e.set(t, r);
|
|
256
256
|
}
|
|
257
257
|
return e;
|
|
258
258
|
}
|
|
259
259
|
toObject() {
|
|
260
260
|
const e = {};
|
|
261
|
-
for (const [t,
|
|
262
|
-
const
|
|
263
|
-
|
|
261
|
+
for (const [t, n] of this._elements) {
|
|
262
|
+
const r = e[t] ?? [];
|
|
263
|
+
r.push(n), e[t] = r;
|
|
264
264
|
}
|
|
265
265
|
return e;
|
|
266
266
|
}
|
|
@@ -280,7 +280,7 @@ class m {
|
|
|
280
280
|
return new m(this._elements.unique());
|
|
281
281
|
}
|
|
282
282
|
byKey(e) {
|
|
283
|
-
return new f(this._elements.map((t,
|
|
283
|
+
return new f(this._elements.map((t, n) => [e(t, n), t]));
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
class p {
|
|
@@ -288,10 +288,10 @@ class p {
|
|
|
288
288
|
u(this, "_resolve");
|
|
289
289
|
u(this, "_reject");
|
|
290
290
|
u(this, "_promise");
|
|
291
|
-
let
|
|
291
|
+
let n, r;
|
|
292
292
|
this._promise = new Promise((o, i) => {
|
|
293
|
-
|
|
294
|
-
}).then(e, t), this._resolve =
|
|
293
|
+
n = o, r = i;
|
|
294
|
+
}).then(e, t), this._resolve = n, this._reject = r;
|
|
295
295
|
}
|
|
296
296
|
get resolve() {
|
|
297
297
|
return this._resolve;
|
|
@@ -322,25 +322,25 @@ class x {
|
|
|
322
322
|
u(this, "_persistent");
|
|
323
323
|
this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
|
|
324
324
|
}
|
|
325
|
-
_get(e, t,
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
325
|
+
_get(e, t, n) {
|
|
326
|
+
const r = e.getItem(t);
|
|
327
|
+
if (r)
|
|
328
328
|
try {
|
|
329
|
-
return JSON.parse(
|
|
329
|
+
return JSON.parse(r);
|
|
330
330
|
} catch {
|
|
331
331
|
console.warn(
|
|
332
|
-
`The "${
|
|
332
|
+
`The "${r}" value for "${t}" property cannot be parsed. Clearing the storage...`
|
|
333
333
|
), e.removeItem(t);
|
|
334
334
|
}
|
|
335
|
-
return
|
|
335
|
+
return n;
|
|
336
336
|
}
|
|
337
|
-
_set(e, t,
|
|
338
|
-
const
|
|
339
|
-
|
|
337
|
+
_set(e, t, n) {
|
|
338
|
+
const r = JSON.stringify(n);
|
|
339
|
+
r ? e.setItem(t, r) : e.removeItem(t);
|
|
340
340
|
}
|
|
341
|
-
get(e, t,
|
|
342
|
-
const
|
|
343
|
-
return this._get(
|
|
341
|
+
get(e, t, n = this._preferPersistence) {
|
|
342
|
+
const r = n ? this._persistent : this._volatile;
|
|
343
|
+
return this._get(r, e, t);
|
|
344
344
|
}
|
|
345
345
|
recall(e, t) {
|
|
346
346
|
return this._get(this._volatile, e, t);
|
|
@@ -401,9 +401,9 @@ class x {
|
|
|
401
401
|
* @param newValue The new value to set.
|
|
402
402
|
* @param persistent Whether to use the persistent `localStorage` or the volatile `sessionStorage`.
|
|
403
403
|
*/
|
|
404
|
-
set(e, t,
|
|
405
|
-
const
|
|
406
|
-
this._set(
|
|
404
|
+
set(e, t, n = this._preferPersistence) {
|
|
405
|
+
const r = n ? this._persistent : this._volatile;
|
|
406
|
+
this._set(r, e, t);
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
409
|
* Sets the value with the specified name in the volatile `sessionStorage`.
|
|
@@ -497,19 +497,19 @@ function S(s, e, t = 864e5) {
|
|
|
497
497
|
}
|
|
498
498
|
function j(s, e, t = 864e5) {
|
|
499
499
|
return new c(function* () {
|
|
500
|
-
const
|
|
501
|
-
let
|
|
502
|
-
for (;
|
|
503
|
-
yield new Date(
|
|
500
|
+
const n = e.getTime();
|
|
501
|
+
let r = s.getTime();
|
|
502
|
+
for (; r < n; )
|
|
503
|
+
yield new Date(r), r += t;
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
function I(s, e = 864e5) {
|
|
507
507
|
return new Date(Math.floor(s.getTime() / e) * e);
|
|
508
508
|
}
|
|
509
509
|
async function A(s, e = "text/javascript") {
|
|
510
|
-
return new Promise((t,
|
|
511
|
-
const
|
|
512
|
-
|
|
510
|
+
return new Promise((t, n) => {
|
|
511
|
+
const r = document.createElement("script");
|
|
512
|
+
r.async = !0, r.defer = !0, r.src = s, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
|
|
513
513
|
});
|
|
514
514
|
}
|
|
515
515
|
function T(s) {
|
|
@@ -523,15 +523,15 @@ function T(s) {
|
|
|
523
523
|
function P(s, e, t = 1) {
|
|
524
524
|
return new c(function* () {
|
|
525
525
|
e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
|
|
526
|
-
for (let
|
|
527
|
-
yield
|
|
526
|
+
for (let n = s; n < e; n += t)
|
|
527
|
+
yield n;
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
function q(s) {
|
|
531
531
|
const e = Array.from(s);
|
|
532
532
|
for (let t = e.length - 1; t > 0; t -= 1) {
|
|
533
|
-
const
|
|
534
|
-
[e[t], e[
|
|
533
|
+
const n = Math.floor(Math.random() * (t + 1));
|
|
534
|
+
[e[t], e[n]] = [e[n], e[t]];
|
|
535
535
|
}
|
|
536
536
|
return e;
|
|
537
537
|
}
|
|
@@ -544,32 +544,32 @@ function C(s) {
|
|
|
544
544
|
}
|
|
545
545
|
function y(s, e) {
|
|
546
546
|
return new c(function* () {
|
|
547
|
-
const t = s[Symbol.iterator](),
|
|
547
|
+
const t = s[Symbol.iterator](), n = e[Symbol.iterator]();
|
|
548
548
|
for (; ; ) {
|
|
549
|
-
const
|
|
550
|
-
if (
|
|
549
|
+
const r = t.next(), o = n.next();
|
|
550
|
+
if (r.done || o.done)
|
|
551
551
|
break;
|
|
552
|
-
yield [
|
|
552
|
+
yield [r.value, o.value];
|
|
553
553
|
}
|
|
554
554
|
});
|
|
555
555
|
}
|
|
556
556
|
function E(s, e) {
|
|
557
557
|
if (e === void 0) {
|
|
558
|
-
let
|
|
558
|
+
let r = 0, o = 0;
|
|
559
559
|
for (const i of s)
|
|
560
|
-
|
|
561
|
-
return
|
|
560
|
+
r += i, o += 1;
|
|
561
|
+
return r / o;
|
|
562
562
|
}
|
|
563
|
-
let t = 0,
|
|
564
|
-
for (const [
|
|
565
|
-
t +=
|
|
566
|
-
return t /
|
|
563
|
+
let t = 0, n = 0;
|
|
564
|
+
for (const [r, o] of y(s, e))
|
|
565
|
+
t += r * o, n += o;
|
|
566
|
+
return t / n;
|
|
567
567
|
}
|
|
568
568
|
function O(s) {
|
|
569
569
|
let e = 0;
|
|
570
570
|
for (let t = 0; t < s.length; t += 1) {
|
|
571
|
-
const
|
|
572
|
-
e = (e << 5) - e +
|
|
571
|
+
const n = s.charCodeAt(t);
|
|
572
|
+
e = (e << 5) - e + n, e |= 0;
|
|
573
573
|
}
|
|
574
574
|
return e;
|
|
575
575
|
}
|
|
@@ -582,7 +582,7 @@ function $(s) {
|
|
|
582
582
|
function R(s) {
|
|
583
583
|
return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
|
|
584
584
|
}
|
|
585
|
-
const F = "1.3.0
|
|
585
|
+
const F = "1.3.0";
|
|
586
586
|
export {
|
|
587
587
|
f as AggregatedIterator,
|
|
588
588
|
m as Aggregator,
|