@byloth/core 1.5.0-rc.4 → 1.5.0-rc.6
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 +459 -161
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +2 -2
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +7 -6
- package/src/core/types.ts +5 -0
- package/src/index.ts +24 -20
- package/src/models/aggregators/aggregated-async-iterator.ts +289 -0
- package/src/models/aggregators/aggregated-iterator.ts +3 -3
- package/src/models/aggregators/aggregator.ts +46 -0
- package/src/models/aggregators/async-aggregator.ts +46 -0
- package/src/models/aggregators/index.ts +4 -47
- package/src/models/aggregators/reduced-iterator.ts +2 -2
- package/src/models/aggregators/types.ts +9 -0
- package/src/models/index.ts +11 -11
- package/src/models/iterators/index.ts +4 -0
- package/src/models/iterators/smart-async-iterator.ts +208 -0
- package/src/models/{smart-iterator.ts → iterators/smart-iterator.ts} +1 -1
- package/src/models/iterators/types.ts +14 -0
- package/src/models/promises/deferred-promise.ts +17 -9
- package/src/models/promises/smart-promise.ts +1 -1
- package/src/models/promises/timed-promise.ts +1 -1
- package/src/models/promises/types.ts +8 -0
- package/src/models/types.ts +22 -0
- package/src/utils/dom.ts +1 -1
- package/src/utils/iterator.ts +11 -0
- package/src/utils/math.ts +6 -1
- package/src/utils/random.ts +14 -10
- package/src/types.ts +0 -21
package/dist/core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (
|
|
4
|
-
class
|
|
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);
|
|
4
|
+
class a {
|
|
5
5
|
constructor(e) {
|
|
6
6
|
u(this, "_iterator");
|
|
7
7
|
u(this, "return");
|
|
@@ -32,7 +32,7 @@ class l {
|
|
|
32
32
|
}
|
|
33
33
|
filter(e) {
|
|
34
34
|
const t = this._iterator;
|
|
35
|
-
return new
|
|
35
|
+
return new a(function* () {
|
|
36
36
|
let n = 0;
|
|
37
37
|
for (; ; ) {
|
|
38
38
|
const r = t.next();
|
|
@@ -44,7 +44,7 @@ class l {
|
|
|
44
44
|
}
|
|
45
45
|
map(e) {
|
|
46
46
|
const t = this._iterator;
|
|
47
|
-
return new
|
|
47
|
+
return new a(function* () {
|
|
48
48
|
let n = 0;
|
|
49
49
|
for (; ; ) {
|
|
50
50
|
const r = t.next();
|
|
@@ -57,16 +57,16 @@ class l {
|
|
|
57
57
|
reduce(e, t) {
|
|
58
58
|
let n = 0, r = t;
|
|
59
59
|
if (r === void 0) {
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
60
|
+
const s = this._iterator.next();
|
|
61
|
+
if (s.done)
|
|
62
62
|
throw new TypeError("Reduce of empty iterator with no initial value");
|
|
63
|
-
r =
|
|
63
|
+
r = s.value, n += 1;
|
|
64
64
|
}
|
|
65
65
|
for (; ; ) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
66
|
+
const s = this._iterator.next();
|
|
67
|
+
if (s.done)
|
|
68
68
|
return r;
|
|
69
|
-
r = e(r,
|
|
69
|
+
r = e(r, s.value, n), n += 1;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
enumerate() {
|
|
@@ -74,7 +74,7 @@ class l {
|
|
|
74
74
|
}
|
|
75
75
|
unique() {
|
|
76
76
|
const e = this._iterator;
|
|
77
|
-
return new
|
|
77
|
+
return new a(function* () {
|
|
78
78
|
const t = /* @__PURE__ */ new Set();
|
|
79
79
|
for (; ; ) {
|
|
80
80
|
const n = e.next();
|
|
@@ -114,28 +114,147 @@ class l {
|
|
|
114
114
|
return this;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
class f {
|
|
118
|
+
constructor(e) {
|
|
119
|
+
u(this, "_iterator");
|
|
120
|
+
u(this, "return");
|
|
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));
|
|
123
|
+
}
|
|
124
|
+
async every(e) {
|
|
125
|
+
let t = 0;
|
|
126
|
+
for (; ; ) {
|
|
127
|
+
const n = await this._iterator.next();
|
|
128
|
+
if (n.done)
|
|
129
|
+
return !0;
|
|
130
|
+
if (!e(n.value, t))
|
|
131
|
+
return !1;
|
|
132
|
+
t += 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async some(e) {
|
|
136
|
+
let t = 0;
|
|
137
|
+
for (; ; ) {
|
|
138
|
+
const n = await this._iterator.next();
|
|
139
|
+
if (n.done)
|
|
140
|
+
return !1;
|
|
141
|
+
if (e(n.value, t))
|
|
142
|
+
return !0;
|
|
143
|
+
t += 1;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
filter(e) {
|
|
147
|
+
const t = this._iterator;
|
|
148
|
+
return new f(async function* () {
|
|
149
|
+
let n = 0;
|
|
150
|
+
for (; ; ) {
|
|
151
|
+
const r = await t.next();
|
|
152
|
+
if (r.done)
|
|
153
|
+
return r.value;
|
|
154
|
+
e(r.value, n) && (yield r.value), n += 1;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
map(e) {
|
|
159
|
+
const t = this._iterator;
|
|
160
|
+
return new f(async function* () {
|
|
161
|
+
let n = 0;
|
|
162
|
+
for (; ; ) {
|
|
163
|
+
const r = await t.next();
|
|
164
|
+
if (r.done)
|
|
165
|
+
return r.value;
|
|
166
|
+
yield e(r.value, n), n += 1;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
async reduce(e, t) {
|
|
171
|
+
let n = 0, r = t;
|
|
172
|
+
if (r === void 0) {
|
|
173
|
+
const s = await this._iterator.next();
|
|
174
|
+
if (s.done)
|
|
175
|
+
throw new TypeError("Reduce of empty iterator with no initial value");
|
|
176
|
+
r = s.value, n += 1;
|
|
177
|
+
}
|
|
178
|
+
for (; ; ) {
|
|
179
|
+
const s = await this._iterator.next();
|
|
180
|
+
if (s.done)
|
|
181
|
+
return r;
|
|
182
|
+
r = await e(r, s.value, n), n += 1;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
enumerate() {
|
|
186
|
+
return this.map((e, t) => [t, e]);
|
|
187
|
+
}
|
|
188
|
+
unique() {
|
|
189
|
+
const e = this._iterator;
|
|
190
|
+
return new f(async function* () {
|
|
191
|
+
const t = /* @__PURE__ */ new Set();
|
|
192
|
+
for (; ; ) {
|
|
193
|
+
const n = await e.next();
|
|
194
|
+
if (n.done)
|
|
195
|
+
return n.value;
|
|
196
|
+
t.has(n.value) || (t.add(n.value), yield n.value);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async count() {
|
|
201
|
+
let e = 0;
|
|
202
|
+
for (; ; ) {
|
|
203
|
+
if ((await this._iterator.next()).done)
|
|
204
|
+
return e;
|
|
205
|
+
e += 1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async forEach(e) {
|
|
209
|
+
let t = 0;
|
|
210
|
+
for (; ; ) {
|
|
211
|
+
const n = await this._iterator.next();
|
|
212
|
+
if (n.done)
|
|
213
|
+
return;
|
|
214
|
+
await e(n.value, t), t += 1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
next(...e) {
|
|
218
|
+
return this._iterator.next(...e);
|
|
219
|
+
}
|
|
220
|
+
async toArray() {
|
|
221
|
+
const e = [];
|
|
222
|
+
for (; ; ) {
|
|
223
|
+
const t = await this._iterator.next();
|
|
224
|
+
if (t.done)
|
|
225
|
+
return e;
|
|
226
|
+
e.push(t.value);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
get [Symbol.toStringTag]() {
|
|
230
|
+
return "SmartAsyncIterator";
|
|
231
|
+
}
|
|
232
|
+
[Symbol.asyncIterator]() {
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
117
236
|
class c {
|
|
118
237
|
constructor(e) {
|
|
119
238
|
u(this, "_elements");
|
|
120
|
-
this._elements = new
|
|
239
|
+
this._elements = new a(e);
|
|
121
240
|
}
|
|
122
241
|
filter(e) {
|
|
123
242
|
const t = this._elements;
|
|
124
243
|
return new c(function* () {
|
|
125
|
-
for (const [n, [r,
|
|
126
|
-
e(r,
|
|
244
|
+
for (const [n, [r, s]] of t.enumerate())
|
|
245
|
+
e(r, s, n) && (yield [r, s]);
|
|
127
246
|
});
|
|
128
247
|
}
|
|
129
248
|
map(e) {
|
|
130
249
|
const t = this._elements;
|
|
131
250
|
return new c(function* () {
|
|
132
|
-
for (const [n, [r,
|
|
133
|
-
yield [r, e(r,
|
|
251
|
+
for (const [n, [r, s]] of t.enumerate())
|
|
252
|
+
yield [r, e(r, s, n)];
|
|
134
253
|
});
|
|
135
254
|
}
|
|
136
255
|
keys() {
|
|
137
256
|
const e = this._elements;
|
|
138
|
-
return new
|
|
257
|
+
return new a(function* () {
|
|
139
258
|
for (const [t] of e)
|
|
140
259
|
yield t;
|
|
141
260
|
});
|
|
@@ -145,7 +264,7 @@ class c {
|
|
|
145
264
|
}
|
|
146
265
|
values() {
|
|
147
266
|
const e = this._elements;
|
|
148
|
-
return new
|
|
267
|
+
return new a(function* () {
|
|
149
268
|
for (const [t, n] of e)
|
|
150
269
|
yield n;
|
|
151
270
|
});
|
|
@@ -163,79 +282,79 @@ class c {
|
|
|
163
282
|
return "ReducedIterator";
|
|
164
283
|
}
|
|
165
284
|
}
|
|
166
|
-
class
|
|
285
|
+
class d {
|
|
167
286
|
constructor(e) {
|
|
168
287
|
u(this, "_elements");
|
|
169
|
-
this._elements = new
|
|
288
|
+
this._elements = new a(e);
|
|
170
289
|
}
|
|
171
290
|
every(e) {
|
|
172
291
|
const t = /* @__PURE__ */ new Map();
|
|
173
292
|
for (const [n, r] of this._elements) {
|
|
174
|
-
const [
|
|
175
|
-
i && t.set(n, [
|
|
293
|
+
const [s, i] = t.get(n) ?? [0, !0];
|
|
294
|
+
i && t.set(n, [s + 1, e(n, r, s)]);
|
|
176
295
|
}
|
|
177
296
|
return new c(function* () {
|
|
178
|
-
for (const [n, [r,
|
|
179
|
-
yield [n,
|
|
297
|
+
for (const [n, [r, s]] of t)
|
|
298
|
+
yield [n, s];
|
|
180
299
|
});
|
|
181
300
|
}
|
|
182
301
|
some(e) {
|
|
183
302
|
const t = /* @__PURE__ */ new Map();
|
|
184
303
|
for (const [n, r] of this._elements) {
|
|
185
|
-
const [
|
|
186
|
-
i || t.set(n, [
|
|
304
|
+
const [s, i] = t.get(n) ?? [0, !1];
|
|
305
|
+
i || t.set(n, [s + 1, e(n, r, s)]);
|
|
187
306
|
}
|
|
188
307
|
return new c(function* () {
|
|
189
|
-
for (const [n, [r,
|
|
190
|
-
yield [n,
|
|
308
|
+
for (const [n, [r, s]] of t)
|
|
309
|
+
yield [n, s];
|
|
191
310
|
});
|
|
192
311
|
}
|
|
193
312
|
filter(e) {
|
|
194
313
|
const t = this._elements;
|
|
195
|
-
return new
|
|
314
|
+
return new d(function* () {
|
|
196
315
|
const n = /* @__PURE__ */ new Map();
|
|
197
|
-
for (const [r,
|
|
316
|
+
for (const [r, s] of t) {
|
|
198
317
|
const i = n.get(r) ?? 0;
|
|
199
|
-
n.set(r, i + 1), e(r,
|
|
318
|
+
n.set(r, i + 1), e(r, s, i) && (yield [r, s]);
|
|
200
319
|
}
|
|
201
320
|
});
|
|
202
321
|
}
|
|
203
322
|
map(e) {
|
|
204
323
|
const t = this._elements;
|
|
205
|
-
return new
|
|
324
|
+
return new d(function* () {
|
|
206
325
|
const n = /* @__PURE__ */ new Map();
|
|
207
|
-
for (const [r,
|
|
326
|
+
for (const [r, s] of t) {
|
|
208
327
|
const i = n.get(r) ?? 0;
|
|
209
|
-
n.set(r, i + 1), yield [r, e(r,
|
|
328
|
+
n.set(r, i + 1), yield [r, e(r, s, i)];
|
|
210
329
|
}
|
|
211
330
|
});
|
|
212
331
|
}
|
|
213
332
|
reduce(e, t) {
|
|
214
333
|
const n = /* @__PURE__ */ new Map();
|
|
215
|
-
for (const [r,
|
|
216
|
-
let i,
|
|
334
|
+
for (const [r, s] of this._elements) {
|
|
335
|
+
let i, l;
|
|
217
336
|
if (n.has(r))
|
|
218
|
-
[i,
|
|
337
|
+
[i, l] = n.get(r), i += 1;
|
|
219
338
|
else if (t !== void 0)
|
|
220
|
-
i = 0,
|
|
339
|
+
i = 0, l = t(r);
|
|
221
340
|
else {
|
|
222
|
-
n.set(r, [0,
|
|
341
|
+
n.set(r, [0, s]);
|
|
223
342
|
continue;
|
|
224
343
|
}
|
|
225
|
-
|
|
344
|
+
l = e(r, l, s, i), n.set(r, [i, l]);
|
|
226
345
|
}
|
|
227
346
|
return new c(function* () {
|
|
228
|
-
for (const [r, [
|
|
347
|
+
for (const [r, [s, i]] of n)
|
|
229
348
|
yield [r, i];
|
|
230
349
|
});
|
|
231
350
|
}
|
|
232
351
|
unique() {
|
|
233
352
|
const e = this._elements;
|
|
234
|
-
return new
|
|
353
|
+
return new d(function* () {
|
|
235
354
|
const t = /* @__PURE__ */ new Map();
|
|
236
355
|
for (const [n, r] of e) {
|
|
237
|
-
const
|
|
238
|
-
|
|
356
|
+
const s = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
357
|
+
s.has(r) || (s.add(r), t.set(n, s), yield [n, r]);
|
|
239
358
|
}
|
|
240
359
|
});
|
|
241
360
|
}
|
|
@@ -270,7 +389,7 @@ class h {
|
|
|
270
389
|
}
|
|
271
390
|
keys() {
|
|
272
391
|
const e = this._elements;
|
|
273
|
-
return new
|
|
392
|
+
return new a(function* () {
|
|
274
393
|
for (const [t] of e)
|
|
275
394
|
yield t;
|
|
276
395
|
});
|
|
@@ -280,7 +399,7 @@ class h {
|
|
|
280
399
|
}
|
|
281
400
|
values() {
|
|
282
401
|
const e = this._elements;
|
|
283
|
-
return new
|
|
402
|
+
return new a(function* () {
|
|
284
403
|
for (const [t, n] of e)
|
|
285
404
|
yield n;
|
|
286
405
|
});
|
|
@@ -308,36 +427,203 @@ class h {
|
|
|
308
427
|
return "AggregatedIterator";
|
|
309
428
|
}
|
|
310
429
|
}
|
|
311
|
-
class
|
|
430
|
+
class y {
|
|
312
431
|
constructor(e) {
|
|
313
432
|
u(this, "_elements");
|
|
314
|
-
this._elements = new
|
|
433
|
+
this._elements = new a(e);
|
|
315
434
|
}
|
|
316
435
|
filter(e) {
|
|
317
|
-
return new
|
|
436
|
+
return new y(this._elements.filter(e));
|
|
318
437
|
}
|
|
319
438
|
map(e) {
|
|
320
|
-
return new
|
|
439
|
+
return new y(this._elements.map(e));
|
|
321
440
|
}
|
|
322
441
|
unique() {
|
|
323
|
-
return new
|
|
442
|
+
return new y(this._elements.unique());
|
|
324
443
|
}
|
|
325
444
|
groupBy(e) {
|
|
326
|
-
return new
|
|
445
|
+
return new d(this._elements.map((t, n) => [e(t, n), t]));
|
|
327
446
|
}
|
|
328
447
|
get [Symbol.toStringTag]() {
|
|
329
448
|
return "Aggregator";
|
|
330
449
|
}
|
|
331
450
|
}
|
|
332
|
-
class
|
|
451
|
+
class w {
|
|
452
|
+
constructor(e) {
|
|
453
|
+
u(this, "_elements");
|
|
454
|
+
this._elements = new f(e);
|
|
455
|
+
}
|
|
456
|
+
async every(e) {
|
|
457
|
+
const t = /* @__PURE__ */ new Map();
|
|
458
|
+
for await (const [n, r] of this._elements) {
|
|
459
|
+
const [s, i] = t.get(n) ?? [0, !0];
|
|
460
|
+
i && t.set(n, [s + 1, await e(n, r, s)]);
|
|
461
|
+
}
|
|
462
|
+
return new c(function* () {
|
|
463
|
+
for (const [n, [r, s]] of t)
|
|
464
|
+
yield [n, s];
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
async some(e) {
|
|
468
|
+
const t = /* @__PURE__ */ new Map();
|
|
469
|
+
for await (const [n, r] of this._elements) {
|
|
470
|
+
const [s, i] = t.get(n) ?? [0, !1];
|
|
471
|
+
i || t.set(n, [s + 1, await e(n, r, s)]);
|
|
472
|
+
}
|
|
473
|
+
return new c(function* () {
|
|
474
|
+
for (const [n, [r, s]] of t)
|
|
475
|
+
yield [n, s];
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
filter(e) {
|
|
479
|
+
const t = this._elements;
|
|
480
|
+
return new w(async function* () {
|
|
481
|
+
const n = /* @__PURE__ */ new Map();
|
|
482
|
+
for await (const [r, s] of t) {
|
|
483
|
+
const i = n.get(r) ?? 0;
|
|
484
|
+
n.set(r, i + 1), e(r, s, i) && (yield [r, s]);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
map(e) {
|
|
489
|
+
const t = this._elements;
|
|
490
|
+
return new w(async function* () {
|
|
491
|
+
const n = /* @__PURE__ */ new Map();
|
|
492
|
+
for await (const [r, s] of t) {
|
|
493
|
+
const i = n.get(r) ?? 0;
|
|
494
|
+
n.set(r, i + 1), yield [r, await e(r, s, i)];
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
async reduce(e, t) {
|
|
499
|
+
const n = /* @__PURE__ */ new Map();
|
|
500
|
+
for await (const [r, s] of this._elements) {
|
|
501
|
+
let i, l;
|
|
502
|
+
if (n.has(r))
|
|
503
|
+
[i, l] = n.get(r), i += 1;
|
|
504
|
+
else if (t !== void 0)
|
|
505
|
+
i = 0, l = t(r);
|
|
506
|
+
else {
|
|
507
|
+
n.set(r, [0, s]);
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
l = await e(r, l, s, i), n.set(r, [i, l]);
|
|
511
|
+
}
|
|
512
|
+
return new c(function* () {
|
|
513
|
+
for (const [r, [s, i]] of n)
|
|
514
|
+
yield [r, i];
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
unique() {
|
|
518
|
+
const e = this._elements;
|
|
519
|
+
return new w(async function* () {
|
|
520
|
+
const t = /* @__PURE__ */ new Map();
|
|
521
|
+
for await (const [n, r] of e) {
|
|
522
|
+
const s = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
523
|
+
s.has(r) || (s.add(r), t.set(n, s), yield [n, r]);
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
async count() {
|
|
528
|
+
const e = /* @__PURE__ */ new Map();
|
|
529
|
+
for await (const [t] of this._elements) {
|
|
530
|
+
const n = e.get(t) ?? 0;
|
|
531
|
+
e.set(t, n + 1);
|
|
532
|
+
}
|
|
533
|
+
return new c(function* () {
|
|
534
|
+
for (const [t, n] of e)
|
|
535
|
+
yield [t, n];
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
async first() {
|
|
539
|
+
const e = /* @__PURE__ */ new Map();
|
|
540
|
+
for await (const [t, n] of this._elements)
|
|
541
|
+
e.has(t) || e.set(t, n);
|
|
542
|
+
return new c(function* () {
|
|
543
|
+
for (const [t, n] of e)
|
|
544
|
+
yield [t, n];
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
async last() {
|
|
548
|
+
const e = /* @__PURE__ */ new Map();
|
|
549
|
+
for await (const [t, n] of this._elements)
|
|
550
|
+
e.set(t, n);
|
|
551
|
+
return new c(function* () {
|
|
552
|
+
for (const [t, n] of e)
|
|
553
|
+
yield [t, n];
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
keys() {
|
|
557
|
+
const e = this._elements;
|
|
558
|
+
return new f(async function* () {
|
|
559
|
+
for await (const [t] of e)
|
|
560
|
+
yield t;
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
items() {
|
|
564
|
+
return this._elements;
|
|
565
|
+
}
|
|
566
|
+
values() {
|
|
567
|
+
const e = this._elements;
|
|
568
|
+
return new f(async function* () {
|
|
569
|
+
for await (const [t, n] of e)
|
|
570
|
+
yield n;
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
async toArray() {
|
|
574
|
+
const e = await this.toMap();
|
|
575
|
+
return Array.from(e.values());
|
|
576
|
+
}
|
|
577
|
+
async toMap() {
|
|
578
|
+
const e = /* @__PURE__ */ new Map();
|
|
579
|
+
for await (const [t, n] of this._elements) {
|
|
580
|
+
const r = e.get(t) ?? [];
|
|
581
|
+
r.push(n), e.set(t, r);
|
|
582
|
+
}
|
|
583
|
+
return e;
|
|
584
|
+
}
|
|
585
|
+
async toObject() {
|
|
586
|
+
const e = {};
|
|
587
|
+
for await (const [t, n] of this._elements) {
|
|
588
|
+
const r = e[t] ?? [];
|
|
589
|
+
r.push(n), e[t] = r;
|
|
590
|
+
}
|
|
591
|
+
return e;
|
|
592
|
+
}
|
|
593
|
+
get [Symbol.toStringTag]() {
|
|
594
|
+
return "AggregatedAsyncIterator";
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
class _ {
|
|
598
|
+
constructor(e) {
|
|
599
|
+
u(this, "_elements");
|
|
600
|
+
this._elements = new f(e);
|
|
601
|
+
}
|
|
602
|
+
filter(e) {
|
|
603
|
+
return new _(this._elements.filter(e));
|
|
604
|
+
}
|
|
605
|
+
map(e) {
|
|
606
|
+
return new _(this._elements.map(e));
|
|
607
|
+
}
|
|
608
|
+
unique() {
|
|
609
|
+
return new _(this._elements.unique());
|
|
610
|
+
}
|
|
611
|
+
groupBy(e) {
|
|
612
|
+
return new w(this._elements.map(async (t, n) => [await e(t, n), t]));
|
|
613
|
+
}
|
|
614
|
+
get [Symbol.toStringTag]() {
|
|
615
|
+
return "AsyncAggregator";
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
class h extends Error {
|
|
333
619
|
static FromUnknown(e) {
|
|
334
|
-
if (e instanceof
|
|
620
|
+
if (e instanceof h)
|
|
335
621
|
return e;
|
|
336
622
|
if (e instanceof Error) {
|
|
337
|
-
const t = new
|
|
623
|
+
const t = new h(e.message);
|
|
338
624
|
return t.stack = e.stack, t.name = e.name, t;
|
|
339
625
|
}
|
|
340
|
-
return new
|
|
626
|
+
return new h(`${e}`);
|
|
341
627
|
}
|
|
342
628
|
constructor(e, t, n = "Exception") {
|
|
343
629
|
super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
|
|
@@ -350,7 +636,7 @@ Caused by ${t}`);
|
|
|
350
636
|
return "Exception";
|
|
351
637
|
}
|
|
352
638
|
}
|
|
353
|
-
class
|
|
639
|
+
class b extends h {
|
|
354
640
|
constructor(e, t, n = "ReferenceException") {
|
|
355
641
|
super(e, t, n);
|
|
356
642
|
}
|
|
@@ -358,7 +644,7 @@ class v extends f {
|
|
|
358
644
|
return "ReferenceException";
|
|
359
645
|
}
|
|
360
646
|
}
|
|
361
|
-
class
|
|
647
|
+
class M extends h {
|
|
362
648
|
constructor(e, t, n = "TimeoutException") {
|
|
363
649
|
super(e, t, n);
|
|
364
650
|
}
|
|
@@ -366,7 +652,7 @@ class x extends f {
|
|
|
366
652
|
return "TimeoutException";
|
|
367
653
|
}
|
|
368
654
|
}
|
|
369
|
-
class
|
|
655
|
+
class m extends h {
|
|
370
656
|
constructor(e, t, n = "ValueException") {
|
|
371
657
|
super(e, t, n);
|
|
372
658
|
}
|
|
@@ -374,7 +660,7 @@ class _ extends f {
|
|
|
374
660
|
return "ValueException";
|
|
375
661
|
}
|
|
376
662
|
}
|
|
377
|
-
class
|
|
663
|
+
class E {
|
|
378
664
|
constructor(e = !0) {
|
|
379
665
|
u(this, "_preferPersistence");
|
|
380
666
|
u(this, "_volatile");
|
|
@@ -512,7 +798,7 @@ class T {
|
|
|
512
798
|
return "JsonStorage";
|
|
513
799
|
}
|
|
514
800
|
}
|
|
515
|
-
class
|
|
801
|
+
class I {
|
|
516
802
|
constructor() {
|
|
517
803
|
u(this, "_subscribers");
|
|
518
804
|
this._subscribers = [];
|
|
@@ -523,7 +809,7 @@ class M {
|
|
|
523
809
|
remove(e) {
|
|
524
810
|
const t = this._subscribers.indexOf(e);
|
|
525
811
|
if (t < 0)
|
|
526
|
-
throw new
|
|
812
|
+
throw new b("Unable to remove the requested subscriber. It was not found.");
|
|
527
813
|
this._subscribers.splice(t, 1);
|
|
528
814
|
}
|
|
529
815
|
call(...e) {
|
|
@@ -533,7 +819,7 @@ class M {
|
|
|
533
819
|
return "Subscribers";
|
|
534
820
|
}
|
|
535
821
|
}
|
|
536
|
-
class
|
|
822
|
+
class v {
|
|
537
823
|
constructor(e) {
|
|
538
824
|
u(this, "_isPending");
|
|
539
825
|
u(this, "_isFulfilled");
|
|
@@ -567,14 +853,15 @@ class w {
|
|
|
567
853
|
return "SmartPromise";
|
|
568
854
|
}
|
|
569
855
|
}
|
|
570
|
-
class
|
|
856
|
+
class R extends v {
|
|
571
857
|
constructor(t, n) {
|
|
572
|
-
|
|
573
|
-
|
|
858
|
+
let r, s;
|
|
859
|
+
super((i, l) => {
|
|
860
|
+
r = i, s = l;
|
|
574
861
|
});
|
|
575
862
|
u(this, "_resolve");
|
|
576
863
|
u(this, "_reject");
|
|
577
|
-
this._promise.then(t, n);
|
|
864
|
+
this._promise.then(t, n), this._resolve = r, this._reject = s;
|
|
578
865
|
}
|
|
579
866
|
get resolve() {
|
|
580
867
|
return this._resolve;
|
|
@@ -589,22 +876,22 @@ class P extends w {
|
|
|
589
876
|
return "DeferredPromise";
|
|
590
877
|
}
|
|
591
878
|
}
|
|
592
|
-
class
|
|
879
|
+
class q extends v {
|
|
593
880
|
constructor(e, t) {
|
|
594
881
|
super((n, r) => {
|
|
595
|
-
const
|
|
596
|
-
clearTimeout(
|
|
597
|
-
}, i = (
|
|
598
|
-
clearTimeout(
|
|
599
|
-
},
|
|
600
|
-
e(
|
|
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);
|
|
887
|
+
e(s, i);
|
|
601
888
|
});
|
|
602
889
|
}
|
|
603
890
|
get [Symbol.toStringTag]() {
|
|
604
891
|
return "TimedPromise";
|
|
605
892
|
}
|
|
606
893
|
}
|
|
607
|
-
class
|
|
894
|
+
class x {
|
|
608
895
|
static Boolean(e = 0.5) {
|
|
609
896
|
return Math.random() < e;
|
|
610
897
|
}
|
|
@@ -612,150 +899,161 @@ class E {
|
|
|
612
899
|
return Math.floor(t === void 0 ? Math.random() * e : Math.random() * (t - e) + e);
|
|
613
900
|
}
|
|
614
901
|
static Decimal(e, t) {
|
|
615
|
-
return t === void 0 ? Math.random() * e : Math.random() * (t - e) + e;
|
|
902
|
+
return e === void 0 ? Math.random() : t === void 0 ? Math.random() * e : Math.random() * (t - e) + e;
|
|
903
|
+
}
|
|
904
|
+
static Index(e) {
|
|
905
|
+
if (e.length === 0)
|
|
906
|
+
throw new m("You must provide at least one element.");
|
|
907
|
+
return this.Integer(e.length);
|
|
616
908
|
}
|
|
617
909
|
static Choice(e) {
|
|
618
|
-
return e[
|
|
910
|
+
return e[x.Index(e)];
|
|
619
911
|
}
|
|
620
912
|
// eslint-disable-next-line no-useless-constructor
|
|
621
913
|
constructor() {
|
|
622
914
|
}
|
|
623
915
|
}
|
|
624
|
-
async function
|
|
625
|
-
return new Promise((e, t) => setTimeout(e,
|
|
916
|
+
async function F(o) {
|
|
917
|
+
return new Promise((e, t) => setTimeout(e, o));
|
|
626
918
|
}
|
|
627
|
-
async function
|
|
628
|
-
return new Promise((
|
|
919
|
+
async function A() {
|
|
920
|
+
return new Promise((o, e) => requestAnimationFrame(() => o()));
|
|
629
921
|
}
|
|
630
|
-
var
|
|
631
|
-
function
|
|
632
|
-
return Math.floor((e.getTime() -
|
|
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) {
|
|
924
|
+
return Math.floor((e.getTime() - o.getTime()) / t);
|
|
633
925
|
}
|
|
634
|
-
function
|
|
635
|
-
return new
|
|
926
|
+
function $(o, e, t = 864e5) {
|
|
927
|
+
return new a(function* () {
|
|
636
928
|
const n = e.getTime();
|
|
637
|
-
let r =
|
|
929
|
+
let r = o.getTime();
|
|
638
930
|
for (; r < n; )
|
|
639
931
|
yield new Date(r), r += t;
|
|
640
932
|
});
|
|
641
933
|
}
|
|
642
|
-
function
|
|
643
|
-
return new Date(Math.floor(
|
|
934
|
+
function C(o, e = 864e5) {
|
|
935
|
+
return new Date(Math.floor(o.getTime() / e) * e);
|
|
644
936
|
}
|
|
645
|
-
|
|
937
|
+
function V(o, e = "text/javascript") {
|
|
646
938
|
return new Promise((t, n) => {
|
|
647
939
|
const r = document.createElement("script");
|
|
648
|
-
r.async = !0, r.defer = !0, r.src =
|
|
940
|
+
r.async = !0, r.defer = !0, r.src = o, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
|
|
649
941
|
});
|
|
650
942
|
}
|
|
651
|
-
function
|
|
652
|
-
if (Array.isArray(
|
|
653
|
-
return
|
|
943
|
+
function Y(o) {
|
|
944
|
+
if (Array.isArray(o))
|
|
945
|
+
return o.length;
|
|
654
946
|
let e = 0;
|
|
655
|
-
for (const t of
|
|
947
|
+
for (const t of o)
|
|
656
948
|
e += 1;
|
|
657
949
|
return e;
|
|
658
950
|
}
|
|
659
|
-
function
|
|
660
|
-
return new
|
|
661
|
-
e === void 0 && (e =
|
|
662
|
-
for (let n =
|
|
951
|
+
function z(o, e, t = 1) {
|
|
952
|
+
return new a(function* () {
|
|
953
|
+
e === void 0 && (e = o, o = 0), o > e && (t = t ?? -1);
|
|
954
|
+
for (let n = o; n < e; n += t)
|
|
663
955
|
yield n;
|
|
664
956
|
});
|
|
665
957
|
}
|
|
666
|
-
function
|
|
667
|
-
const e = Array.from(
|
|
958
|
+
function J(o) {
|
|
959
|
+
const e = Array.from(o);
|
|
668
960
|
for (let t = e.length - 1; t > 0; t -= 1) {
|
|
669
961
|
const n = Math.floor(Math.random() * (t + 1));
|
|
670
962
|
[e[t], e[n]] = [e[n], e[t]];
|
|
671
963
|
}
|
|
672
964
|
return e;
|
|
673
965
|
}
|
|
674
|
-
function
|
|
675
|
-
return new
|
|
966
|
+
function B(o) {
|
|
967
|
+
return new a(function* () {
|
|
676
968
|
const e = /* @__PURE__ */ new Set();
|
|
677
|
-
for (const t of
|
|
969
|
+
for (const t of o)
|
|
678
970
|
e.has(t) || (e.add(t), yield t);
|
|
679
971
|
});
|
|
680
972
|
}
|
|
681
|
-
function
|
|
682
|
-
return new
|
|
683
|
-
const t =
|
|
973
|
+
function j(o, e) {
|
|
974
|
+
return new a(function* () {
|
|
975
|
+
const t = o[Symbol.iterator](), n = e[Symbol.iterator]();
|
|
684
976
|
for (; ; ) {
|
|
685
|
-
const r = t.next(),
|
|
686
|
-
if (r.done ||
|
|
977
|
+
const r = t.next(), s = n.next();
|
|
978
|
+
if (r.done || s.done)
|
|
687
979
|
break;
|
|
688
|
-
yield [r.value,
|
|
980
|
+
yield [r.value, s.value];
|
|
689
981
|
}
|
|
690
982
|
});
|
|
691
983
|
}
|
|
692
|
-
function
|
|
984
|
+
function H(o, e) {
|
|
693
985
|
if (e === void 0) {
|
|
694
|
-
let
|
|
695
|
-
for (const
|
|
696
|
-
|
|
986
|
+
let s = 0, i = 0;
|
|
987
|
+
for (const l of o)
|
|
988
|
+
s += l, i += 1;
|
|
697
989
|
if (i === 0)
|
|
698
|
-
throw new
|
|
699
|
-
return
|
|
990
|
+
throw new m("You must provide at least one value.");
|
|
991
|
+
return s / i;
|
|
700
992
|
}
|
|
701
993
|
let t = 0, n = 0, r = 0;
|
|
702
|
-
for (const [
|
|
703
|
-
|
|
994
|
+
for (const [s, i] of j(o, e)) {
|
|
995
|
+
if (i <= 0)
|
|
996
|
+
throw new m(`The weight for the value #${r} must be greater than zero.`);
|
|
997
|
+
t += s * i, n += i, r += 1;
|
|
998
|
+
}
|
|
704
999
|
if (r === 0)
|
|
705
|
-
throw new
|
|
706
|
-
if (n
|
|
707
|
-
throw new
|
|
1000
|
+
throw new m("You must provide at least one value and weight.");
|
|
1001
|
+
if (n > 0)
|
|
1002
|
+
throw new m("The sum of weights must be greater than zero.");
|
|
708
1003
|
return t / n;
|
|
709
1004
|
}
|
|
710
|
-
function
|
|
1005
|
+
function W(o) {
|
|
711
1006
|
let e = 0;
|
|
712
|
-
for (let t = 0; t <
|
|
713
|
-
const n =
|
|
1007
|
+
for (let t = 0; t < o.length; t += 1) {
|
|
1008
|
+
const n = o.charCodeAt(t);
|
|
714
1009
|
e = (e << 5) - e + n, e |= 0;
|
|
715
1010
|
}
|
|
716
1011
|
return e;
|
|
717
1012
|
}
|
|
718
|
-
function
|
|
1013
|
+
function G(o) {
|
|
719
1014
|
let e = 0;
|
|
720
|
-
for (const t of
|
|
1015
|
+
for (const t of o)
|
|
721
1016
|
e += t;
|
|
722
1017
|
return e;
|
|
723
1018
|
}
|
|
724
|
-
function
|
|
725
|
-
return `${
|
|
1019
|
+
function K(o) {
|
|
1020
|
+
return `${o.charAt(0).toUpperCase()}${o.slice(1)}`;
|
|
726
1021
|
}
|
|
727
|
-
const
|
|
1022
|
+
const L = "1.5.0-rc.6";
|
|
728
1023
|
export {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
1024
|
+
w as AggregatedAsyncIterator,
|
|
1025
|
+
d as AggregatedIterator,
|
|
1026
|
+
y as Aggregator,
|
|
1027
|
+
_ as AsyncAggregator,
|
|
1028
|
+
T as DateUnit,
|
|
1029
|
+
R as DeferredPromise,
|
|
1030
|
+
h as Exception,
|
|
1031
|
+
E as JsonStorage,
|
|
1032
|
+
x as Random,
|
|
736
1033
|
c as ReducedIterator,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
H as
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
1034
|
+
b as ReferenceException,
|
|
1035
|
+
f as SmartAsyncIterator,
|
|
1036
|
+
a as SmartIterator,
|
|
1037
|
+
v as SmartPromise,
|
|
1038
|
+
I as Subscribers,
|
|
1039
|
+
q as TimedPromise,
|
|
1040
|
+
M as TimeoutException,
|
|
1041
|
+
L as VERSION,
|
|
1042
|
+
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
|
|
760
1058
|
};
|
|
761
1059
|
//# sourceMappingURL=core.js.map
|