@rimbu/common 1.0.0 → 2.0.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/bun/async-optlazy.mts +18 -5
- package/dist/bun/internal.mts +0 -2
- package/dist/bun/optlazy.mts +12 -3
- package/dist/cjs/async-optlazy.cjs +4 -4
- package/dist/cjs/comp.cjs +21 -911
- package/dist/cjs/index.cjs +23 -910
- package/dist/cjs/internal.cjs +23 -910
- package/dist/cjs/optlazy.cjs +2 -2
- package/dist/esm/async-optlazy.mjs +10 -4
- package/dist/esm/async-optlazy.mjs.map +1 -1
- package/dist/esm/comp.mjs.map +1 -1
- package/dist/esm/eq.mjs.map +1 -1
- package/dist/esm/index-range.mjs.map +1 -1
- package/dist/esm/internal.mjs +0 -2
- package/dist/esm/internal.mjs.map +1 -1
- package/dist/esm/optlazy.mjs +7 -2
- package/dist/esm/optlazy.mjs.map +1 -1
- package/dist/esm/range.mjs.map +1 -1
- package/dist/esm/update.mjs.map +1 -1
- package/dist/types/async-optlazy.d.mts +10 -3
- package/dist/types/internal.d.mts +0 -2
- package/dist/types/optlazy.d.mts +8 -2
- package/package.json +3 -3
- package/src/async-optlazy.mts +18 -5
- package/src/internal.mts +0 -2
- package/src/optlazy.mts +12 -3
- package/dist/bun/async-reducer.mts +0 -1157
- package/dist/bun/reducer.mts +0 -1025
- package/dist/cjs/async-reducer.cjs +0 -1621
- package/dist/cjs/reducer.cjs +0 -1621
- package/dist/esm/async-reducer.mjs +0 -638
- package/dist/esm/async-reducer.mjs.map +0 -1
- package/dist/esm/reducer.mjs +0 -669
- package/dist/esm/reducer.mjs.map +0 -1
- package/dist/types/async-reducer.d.mts +0 -542
- package/dist/types/reducer.d.mts +0 -542
- package/src/async-reducer.mts +0 -1157
- package/src/reducer.mts +0 -1025
package/dist/cjs/comp.cjs
CHANGED
|
@@ -32,31 +32,31 @@ var CollectFun;
|
|
|
32
32
|
|
|
33
33
|
// src/eq.mts
|
|
34
34
|
var Eq;
|
|
35
|
-
((
|
|
35
|
+
((Eq2) => {
|
|
36
36
|
function convertAnyToString(value) {
|
|
37
37
|
if (typeof value !== "object" || null === value || !("toString" in value) || typeof value.toString !== "function" || value.toString !== Object.prototype.toString) {
|
|
38
38
|
return String(value);
|
|
39
39
|
}
|
|
40
40
|
return JSON.stringify(value);
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
Eq2.convertAnyToString = convertAnyToString;
|
|
43
43
|
const _anyFlatEq = createAnyEq("FLAT");
|
|
44
44
|
const _anyShallowEq = createAnyEq("SHALLOW");
|
|
45
45
|
const _anyDeepEq = createAnyEq("DEEP");
|
|
46
46
|
function defaultEq() {
|
|
47
47
|
return _anyDeepEq;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
Eq2.defaultEq = defaultEq;
|
|
50
|
+
Eq2.objectIs = Object.is;
|
|
51
51
|
const _valueOfEq = (v1, v2) => Object.is(v1.valueOf(), v2.valueOf());
|
|
52
52
|
function valueOfEq() {
|
|
53
53
|
return _valueOfEq;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
Eq2.valueOfEq = valueOfEq;
|
|
56
56
|
function dateEq() {
|
|
57
57
|
return _valueOfEq;
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
Eq2.dateEq = dateEq;
|
|
60
60
|
function createIterableEq(itemEq) {
|
|
61
61
|
return (v1, v2) => {
|
|
62
62
|
if (Object.is(v1, v2))
|
|
@@ -79,7 +79,7 @@ var Eq;
|
|
|
79
79
|
return _iterableAnyEq;
|
|
80
80
|
return createIterableEq(itemEq);
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
Eq2.iterableEq = iterableEq;
|
|
83
83
|
function createObjectEq(valueEq) {
|
|
84
84
|
return (v1, v2) => {
|
|
85
85
|
if (Object.is(v1, v2))
|
|
@@ -109,7 +109,7 @@ var Eq;
|
|
|
109
109
|
return _objectEq;
|
|
110
110
|
return createObjectEq(valueEq);
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
Eq2.objectEq = objectEq;
|
|
113
113
|
function createAnyEq(mode) {
|
|
114
114
|
const result = (v1, v2) => {
|
|
115
115
|
if (Object.is(v1, v2))
|
|
@@ -157,15 +157,15 @@ var Eq;
|
|
|
157
157
|
function anyFlatEq() {
|
|
158
158
|
return _anyFlatEq;
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
Eq2.anyFlatEq = anyFlatEq;
|
|
161
161
|
function anyShallowEq() {
|
|
162
162
|
return _anyShallowEq;
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
Eq2.anyShallowEq = anyShallowEq;
|
|
165
165
|
function anyDeepEq() {
|
|
166
166
|
return _anyDeepEq;
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
Eq2.anyDeepEq = anyDeepEq;
|
|
169
169
|
const _defaultCollator = Intl.Collator("und");
|
|
170
170
|
const _defaultStringCollatorEq = (v1, v2) => _defaultCollator.compare(v1, v2) === 0;
|
|
171
171
|
function createStringCollatorEq(...args) {
|
|
@@ -174,14 +174,14 @@ var Eq;
|
|
|
174
174
|
const collator = Intl.Collator(...args);
|
|
175
175
|
return (v1, v2) => collator.compare(v1, v2) === 0;
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
Eq2.createStringCollatorEq = createStringCollatorEq;
|
|
178
178
|
const _stringCaseInsensitiveEq = createStringCollatorEq("und", {
|
|
179
179
|
sensitivity: "accent"
|
|
180
180
|
});
|
|
181
181
|
function stringCaseInsentitiveEq() {
|
|
182
182
|
return _stringCaseInsensitiveEq;
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
Eq2.stringCaseInsentitiveEq = stringCaseInsentitiveEq;
|
|
185
185
|
const _stringCharCodeEq = (v1, v2) => {
|
|
186
186
|
const len = v1.length;
|
|
187
187
|
if (len !== v2.length)
|
|
@@ -196,21 +196,21 @@ var Eq;
|
|
|
196
196
|
function stringCharCodeEq() {
|
|
197
197
|
return _stringCharCodeEq;
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
Eq2.stringCharCodeEq = stringCharCodeEq;
|
|
200
200
|
const _anyToStringEq = (v1, v2) => convertAnyToString(v1) === convertAnyToString(v2);
|
|
201
201
|
function anyToStringEq() {
|
|
202
202
|
return _anyToStringEq;
|
|
203
203
|
}
|
|
204
|
-
|
|
204
|
+
Eq2.anyToStringEq = anyToStringEq;
|
|
205
205
|
const _anyJsonEq = (v1, v2) => JSON.stringify(v1) === JSON.stringify(v2);
|
|
206
206
|
function anyJsonEq() {
|
|
207
207
|
return _anyJsonEq;
|
|
208
208
|
}
|
|
209
|
-
|
|
209
|
+
Eq2.anyJsonEq = anyJsonEq;
|
|
210
210
|
function tupleSymmetric(eq = defaultEq()) {
|
|
211
211
|
return (tup1, tup2) => eq(tup1[0], tup2[0]) && eq(tup1[1], tup2[1]) || eq(tup1[0], tup2[1]) && eq(tup1[1], tup2[0]);
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
Eq2.tupleSymmetric = tupleSymmetric;
|
|
214
214
|
})(Eq || (Eq = {}));
|
|
215
215
|
|
|
216
216
|
// src/err.mts
|
|
@@ -323,13 +323,6 @@ var IndexRange;
|
|
|
323
323
|
IndexRange2.getIndicesFor = getIndicesFor;
|
|
324
324
|
})(IndexRange || (IndexRange = {}));
|
|
325
325
|
|
|
326
|
-
// src/optlazy.mts
|
|
327
|
-
function OptLazy(optLazy) {
|
|
328
|
-
if (optLazy instanceof Function)
|
|
329
|
-
return optLazy();
|
|
330
|
-
return optLazy;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
326
|
// src/range.mts
|
|
334
327
|
var Range;
|
|
335
328
|
((Range2) => {
|
|
@@ -355,906 +348,23 @@ var Range;
|
|
|
355
348
|
Range2.getNormalizedRange = getNormalizedRange;
|
|
356
349
|
})(Range || (Range = {}));
|
|
357
350
|
|
|
358
|
-
// src/reducer.mts
|
|
359
|
-
function identity(value) {
|
|
360
|
-
return value;
|
|
361
|
-
}
|
|
362
|
-
var Reducer;
|
|
363
|
-
((Reducer3) => {
|
|
364
|
-
class Base {
|
|
365
|
-
constructor(init, next, stateToResult) {
|
|
366
|
-
this.init = init;
|
|
367
|
-
this.next = next;
|
|
368
|
-
this.stateToResult = stateToResult;
|
|
369
|
-
}
|
|
370
|
-
filterInput(pred) {
|
|
371
|
-
return create(
|
|
372
|
-
() => ({
|
|
373
|
-
nextIndex: 0,
|
|
374
|
-
state: OptLazy(this.init)
|
|
375
|
-
}),
|
|
376
|
-
(state, elem, index, halt) => {
|
|
377
|
-
if (pred(elem, index, halt)) {
|
|
378
|
-
state.state = this.next(state.state, elem, state.nextIndex++, halt);
|
|
379
|
-
}
|
|
380
|
-
return state;
|
|
381
|
-
},
|
|
382
|
-
(state) => this.stateToResult(state.state)
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
mapInput(mapFun) {
|
|
386
|
-
return create(
|
|
387
|
-
this.init,
|
|
388
|
-
(state, elem, index, halt) => this.next(state, mapFun(elem, index), index, halt),
|
|
389
|
-
this.stateToResult
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
collectInput(collectFun) {
|
|
393
|
-
return create(
|
|
394
|
-
() => ({
|
|
395
|
-
nextIndex: 0,
|
|
396
|
-
state: OptLazy(this.init)
|
|
397
|
-
}),
|
|
398
|
-
(state, elem, index, halt) => {
|
|
399
|
-
const nextElem = collectFun(elem, index, CollectFun.Skip, halt);
|
|
400
|
-
if (CollectFun.Skip !== nextElem) {
|
|
401
|
-
state.state = this.next(
|
|
402
|
-
state.state,
|
|
403
|
-
nextElem,
|
|
404
|
-
state.nextIndex++,
|
|
405
|
-
halt
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
return state;
|
|
409
|
-
},
|
|
410
|
-
(state) => this.stateToResult(state.state)
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
mapOutput(mapFun) {
|
|
414
|
-
return create(
|
|
415
|
-
this.init,
|
|
416
|
-
this.next,
|
|
417
|
-
(state) => mapFun(this.stateToResult(state))
|
|
418
|
-
);
|
|
419
|
-
}
|
|
420
|
-
takeInput(amount) {
|
|
421
|
-
if (amount <= 0) {
|
|
422
|
-
return create(this.init, identity, this.stateToResult);
|
|
423
|
-
}
|
|
424
|
-
return this.filterInput((_, i, halt) => {
|
|
425
|
-
const more = i < amount;
|
|
426
|
-
if (!more)
|
|
427
|
-
halt();
|
|
428
|
-
return more;
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
dropInput(amount) {
|
|
432
|
-
if (amount <= 0)
|
|
433
|
-
return this;
|
|
434
|
-
return this.filterInput((_, i) => i >= amount);
|
|
435
|
-
}
|
|
436
|
-
sliceInput(from = 0, amount) {
|
|
437
|
-
if (void 0 === amount)
|
|
438
|
-
return this.dropInput(from);
|
|
439
|
-
if (amount <= 0)
|
|
440
|
-
return create(this.init, identity, this.stateToResult);
|
|
441
|
-
if (from <= 0)
|
|
442
|
-
return this.takeInput(amount);
|
|
443
|
-
return this.takeInput(amount).dropInput(from);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
Reducer3.Base = Base;
|
|
447
|
-
function create(init, next, stateToResult) {
|
|
448
|
-
return new Reducer3.Base(init, next, stateToResult);
|
|
449
|
-
}
|
|
450
|
-
Reducer3.create = create;
|
|
451
|
-
function createMono(init, next, stateToResult) {
|
|
452
|
-
return create(init, next, stateToResult ?? identity);
|
|
453
|
-
}
|
|
454
|
-
Reducer3.createMono = createMono;
|
|
455
|
-
function createOutput(init, next, stateToResult) {
|
|
456
|
-
return create(init, next, stateToResult ?? identity);
|
|
457
|
-
}
|
|
458
|
-
Reducer3.createOutput = createOutput;
|
|
459
|
-
Reducer3.sum = createMono(0, (state, next) => state + next);
|
|
460
|
-
Reducer3.product = createMono(1, (state, next, _, halt) => {
|
|
461
|
-
if (0 === next)
|
|
462
|
-
halt();
|
|
463
|
-
return state * next;
|
|
464
|
-
});
|
|
465
|
-
Reducer3.average = createMono(
|
|
466
|
-
0,
|
|
467
|
-
(avg, value, index) => avg + (value - avg) / (index + 1)
|
|
468
|
-
);
|
|
469
|
-
Reducer3.minBy = (compFun, otherwise) => {
|
|
470
|
-
const token = Symbol();
|
|
471
|
-
return create(
|
|
472
|
-
token,
|
|
473
|
-
(state, next) => {
|
|
474
|
-
if (token === state)
|
|
475
|
-
return next;
|
|
476
|
-
return compFun(state, next) < 0 ? state : next;
|
|
477
|
-
},
|
|
478
|
-
(state) => token === state ? OptLazy(otherwise) : state
|
|
479
|
-
);
|
|
480
|
-
};
|
|
481
|
-
Reducer3.min = (otherwise) => {
|
|
482
|
-
return create(
|
|
483
|
-
void 0,
|
|
484
|
-
(state, next) => void 0 !== state && state < next ? state : next,
|
|
485
|
-
(state) => state ?? OptLazy(otherwise)
|
|
486
|
-
);
|
|
487
|
-
};
|
|
488
|
-
Reducer3.maxBy = (compFun, otherwise) => {
|
|
489
|
-
const token = Symbol();
|
|
490
|
-
return create(
|
|
491
|
-
token,
|
|
492
|
-
(state, next) => {
|
|
493
|
-
if (token === state)
|
|
494
|
-
return next;
|
|
495
|
-
return compFun(state, next) > 0 ? state : next;
|
|
496
|
-
},
|
|
497
|
-
(state) => token === state ? OptLazy(otherwise) : state
|
|
498
|
-
);
|
|
499
|
-
};
|
|
500
|
-
Reducer3.max = (otherwise) => {
|
|
501
|
-
return create(
|
|
502
|
-
void 0,
|
|
503
|
-
(state, next) => void 0 !== state && state > next ? state : next,
|
|
504
|
-
(state) => state ?? OptLazy(otherwise)
|
|
505
|
-
);
|
|
506
|
-
};
|
|
507
|
-
function join({
|
|
508
|
-
sep = "",
|
|
509
|
-
start = "",
|
|
510
|
-
end = "",
|
|
511
|
-
valueToString = String
|
|
512
|
-
} = {}) {
|
|
513
|
-
let curSep = "";
|
|
514
|
-
let curStart = start;
|
|
515
|
-
return create(
|
|
516
|
-
"",
|
|
517
|
-
(state, next) => {
|
|
518
|
-
const result = curStart.concat(state, curSep, valueToString(next));
|
|
519
|
-
curSep = sep;
|
|
520
|
-
curStart = "";
|
|
521
|
-
return result;
|
|
522
|
-
},
|
|
523
|
-
(state) => state.concat(end)
|
|
524
|
-
);
|
|
525
|
-
}
|
|
526
|
-
Reducer3.join = join;
|
|
527
|
-
Reducer3.count = (pred) => {
|
|
528
|
-
if (void 0 === pred)
|
|
529
|
-
return createOutput(0, (_, __, i) => i + 1);
|
|
530
|
-
return createOutput(0, (state, next, i) => {
|
|
531
|
-
if (pred?.(next, i))
|
|
532
|
-
return state + 1;
|
|
533
|
-
return state;
|
|
534
|
-
});
|
|
535
|
-
};
|
|
536
|
-
Reducer3.firstWhere = (pred, otherwise) => {
|
|
537
|
-
const token = Symbol();
|
|
538
|
-
return create(
|
|
539
|
-
token,
|
|
540
|
-
(state, next, i, halt) => {
|
|
541
|
-
if (token === state && pred(next, i)) {
|
|
542
|
-
halt();
|
|
543
|
-
return next;
|
|
544
|
-
}
|
|
545
|
-
return state;
|
|
546
|
-
},
|
|
547
|
-
(state) => token === state ? OptLazy(otherwise) : state
|
|
548
|
-
);
|
|
549
|
-
};
|
|
550
|
-
Reducer3.first = (otherwise) => {
|
|
551
|
-
const token = Symbol();
|
|
552
|
-
return create(
|
|
553
|
-
token,
|
|
554
|
-
(state, next, _, halt) => {
|
|
555
|
-
halt();
|
|
556
|
-
if (token === state)
|
|
557
|
-
return next;
|
|
558
|
-
return state;
|
|
559
|
-
},
|
|
560
|
-
(state) => token === state ? OptLazy(otherwise) : state
|
|
561
|
-
);
|
|
562
|
-
};
|
|
563
|
-
Reducer3.lastWhere = (pred, otherwise) => {
|
|
564
|
-
const token = Symbol();
|
|
565
|
-
return create(
|
|
566
|
-
token,
|
|
567
|
-
(state, next, i) => {
|
|
568
|
-
if (pred(next, i))
|
|
569
|
-
return next;
|
|
570
|
-
return state;
|
|
571
|
-
},
|
|
572
|
-
(state) => token === state ? OptLazy(otherwise) : state
|
|
573
|
-
);
|
|
574
|
-
};
|
|
575
|
-
Reducer3.last = (otherwise) => {
|
|
576
|
-
const token = Symbol();
|
|
577
|
-
return create(
|
|
578
|
-
() => token,
|
|
579
|
-
(_, next) => next,
|
|
580
|
-
(state) => token === state ? OptLazy(otherwise) : state
|
|
581
|
-
);
|
|
582
|
-
};
|
|
583
|
-
function some(pred) {
|
|
584
|
-
return createOutput(false, (state, next, i, halt) => {
|
|
585
|
-
if (state)
|
|
586
|
-
return state;
|
|
587
|
-
const satisfies = pred(next, i);
|
|
588
|
-
if (satisfies) {
|
|
589
|
-
halt();
|
|
590
|
-
}
|
|
591
|
-
return satisfies;
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
Reducer3.some = some;
|
|
595
|
-
function every(pred) {
|
|
596
|
-
return createOutput(true, (state, next, i, halt) => {
|
|
597
|
-
if (!state)
|
|
598
|
-
return state;
|
|
599
|
-
const satisfies = pred(next, i);
|
|
600
|
-
if (!satisfies) {
|
|
601
|
-
halt();
|
|
602
|
-
}
|
|
603
|
-
return satisfies;
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
Reducer3.every = every;
|
|
607
|
-
function contains(elem, eq = Object.is) {
|
|
608
|
-
return createOutput(false, (state, next, _, halt) => {
|
|
609
|
-
if (state)
|
|
610
|
-
return state;
|
|
611
|
-
const satisfies = eq(next, elem);
|
|
612
|
-
if (satisfies) {
|
|
613
|
-
halt();
|
|
614
|
-
}
|
|
615
|
-
return satisfies;
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
Reducer3.contains = contains;
|
|
619
|
-
Reducer3.and = createMono(true, (state, next, _, halt) => {
|
|
620
|
-
if (!state)
|
|
621
|
-
return state;
|
|
622
|
-
if (!next)
|
|
623
|
-
halt();
|
|
624
|
-
return next;
|
|
625
|
-
});
|
|
626
|
-
Reducer3.or = createMono(false, (state, next, _, halt) => {
|
|
627
|
-
if (state)
|
|
628
|
-
return state;
|
|
629
|
-
if (next)
|
|
630
|
-
halt();
|
|
631
|
-
return next;
|
|
632
|
-
});
|
|
633
|
-
Reducer3.isEmpty = createOutput(
|
|
634
|
-
true,
|
|
635
|
-
(_, __, ___, halt) => {
|
|
636
|
-
halt();
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
);
|
|
640
|
-
Reducer3.nonEmpty = createOutput(
|
|
641
|
-
false,
|
|
642
|
-
(_, __, ___, halt) => {
|
|
643
|
-
halt();
|
|
644
|
-
return true;
|
|
645
|
-
}
|
|
646
|
-
);
|
|
647
|
-
function toArray() {
|
|
648
|
-
return create(
|
|
649
|
-
() => [],
|
|
650
|
-
(state, next) => {
|
|
651
|
-
state.push(next);
|
|
652
|
-
return state;
|
|
653
|
-
},
|
|
654
|
-
(state) => state.slice()
|
|
655
|
-
);
|
|
656
|
-
}
|
|
657
|
-
Reducer3.toArray = toArray;
|
|
658
|
-
function toJSMap() {
|
|
659
|
-
return create(
|
|
660
|
-
() => /* @__PURE__ */ new Map(),
|
|
661
|
-
(state, next) => {
|
|
662
|
-
state.set(next[0], next[1]);
|
|
663
|
-
return state;
|
|
664
|
-
},
|
|
665
|
-
(s) => new Map(s)
|
|
666
|
-
);
|
|
667
|
-
}
|
|
668
|
-
Reducer3.toJSMap = toJSMap;
|
|
669
|
-
function toJSSet() {
|
|
670
|
-
return create(
|
|
671
|
-
() => /* @__PURE__ */ new Set(),
|
|
672
|
-
(state, next) => {
|
|
673
|
-
state.add(next);
|
|
674
|
-
return state;
|
|
675
|
-
},
|
|
676
|
-
(s) => new Set(s)
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
Reducer3.toJSSet = toJSSet;
|
|
680
|
-
function toJSObject() {
|
|
681
|
-
return create(
|
|
682
|
-
() => ({}),
|
|
683
|
-
(state, entry) => {
|
|
684
|
-
state[entry[0]] = entry[1];
|
|
685
|
-
return state;
|
|
686
|
-
},
|
|
687
|
-
(s) => ({ ...s })
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
Reducer3.toJSObject = toJSObject;
|
|
691
|
-
function combineArr(...reducers) {
|
|
692
|
-
const createState = () => {
|
|
693
|
-
return reducers.map((reducer) => {
|
|
694
|
-
const result = {
|
|
695
|
-
reducer,
|
|
696
|
-
halted: false,
|
|
697
|
-
halt() {
|
|
698
|
-
result.halted = true;
|
|
699
|
-
},
|
|
700
|
-
state: OptLazy(reducer.init)
|
|
701
|
-
};
|
|
702
|
-
return result;
|
|
703
|
-
});
|
|
704
|
-
};
|
|
705
|
-
return create(
|
|
706
|
-
createState,
|
|
707
|
-
(allState, next, index, halt) => {
|
|
708
|
-
let anyNotHalted = false;
|
|
709
|
-
let i = -1;
|
|
710
|
-
const len = allState.length;
|
|
711
|
-
while (++i < len) {
|
|
712
|
-
const red = allState[i];
|
|
713
|
-
if (red.halted) {
|
|
714
|
-
continue;
|
|
715
|
-
}
|
|
716
|
-
red.state = red.reducer.next(red.state, next, index, red.halt);
|
|
717
|
-
if (!red.halted) {
|
|
718
|
-
anyNotHalted = true;
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
if (!anyNotHalted) {
|
|
722
|
-
halt();
|
|
723
|
-
}
|
|
724
|
-
return allState;
|
|
725
|
-
},
|
|
726
|
-
(allState) => allState.map((st) => st.reducer.stateToResult(st.state))
|
|
727
|
-
);
|
|
728
|
-
}
|
|
729
|
-
Reducer3.combineArr = combineArr;
|
|
730
|
-
function combineObj(reducerObj) {
|
|
731
|
-
const createState = () => {
|
|
732
|
-
const allState = {};
|
|
733
|
-
for (const key in reducerObj) {
|
|
734
|
-
const reducer = reducerObj[key];
|
|
735
|
-
const result = {
|
|
736
|
-
reducer,
|
|
737
|
-
halted: false,
|
|
738
|
-
halt() {
|
|
739
|
-
result.halted = true;
|
|
740
|
-
},
|
|
741
|
-
state: OptLazy(reducer.init)
|
|
742
|
-
};
|
|
743
|
-
allState[key] = result;
|
|
744
|
-
}
|
|
745
|
-
return allState;
|
|
746
|
-
};
|
|
747
|
-
return create(
|
|
748
|
-
createState,
|
|
749
|
-
(allState, next, index, halt) => {
|
|
750
|
-
let anyNotHalted = false;
|
|
751
|
-
for (const key in allState) {
|
|
752
|
-
const red = allState[key];
|
|
753
|
-
if (red.halted) {
|
|
754
|
-
continue;
|
|
755
|
-
}
|
|
756
|
-
red.state = red.reducer.next(red.state, next, index, red.halt);
|
|
757
|
-
if (!red.halted) {
|
|
758
|
-
anyNotHalted = true;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
if (!anyNotHalted) {
|
|
762
|
-
halt();
|
|
763
|
-
}
|
|
764
|
-
return allState;
|
|
765
|
-
},
|
|
766
|
-
(allState) => {
|
|
767
|
-
const result = {};
|
|
768
|
-
for (const key in allState) {
|
|
769
|
-
const st = allState[key];
|
|
770
|
-
result[key] = st.reducer.stateToResult(st.state);
|
|
771
|
-
}
|
|
772
|
-
return result;
|
|
773
|
-
}
|
|
774
|
-
);
|
|
775
|
-
}
|
|
776
|
-
Reducer3.combineObj = combineObj;
|
|
777
|
-
})(Reducer || (Reducer = {}));
|
|
778
|
-
|
|
779
351
|
// src/async-optlazy.mts
|
|
780
352
|
var AsyncOptLazy;
|
|
781
353
|
((AsyncOptLazy2) => {
|
|
782
|
-
function toMaybePromise(optLazy) {
|
|
354
|
+
function toMaybePromise(optLazy, ...args) {
|
|
783
355
|
if (optLazy instanceof Function)
|
|
784
|
-
return optLazy();
|
|
356
|
+
return optLazy(...args);
|
|
785
357
|
return optLazy;
|
|
786
358
|
}
|
|
787
359
|
AsyncOptLazy2.toMaybePromise = toMaybePromise;
|
|
788
|
-
async function toPromise(optLazy) {
|
|
360
|
+
async function toPromise(optLazy, ...args) {
|
|
789
361
|
if (optLazy instanceof Function)
|
|
790
|
-
return optLazy();
|
|
362
|
+
return optLazy(...args);
|
|
791
363
|
return optLazy;
|
|
792
364
|
}
|
|
793
365
|
AsyncOptLazy2.toPromise = toPromise;
|
|
794
366
|
})(AsyncOptLazy || (AsyncOptLazy = {}));
|
|
795
367
|
|
|
796
|
-
// src/async-reducer.mts
|
|
797
|
-
function identity2(value) {
|
|
798
|
-
return value;
|
|
799
|
-
}
|
|
800
|
-
var AsyncReducer;
|
|
801
|
-
((AsyncReducer2) => {
|
|
802
|
-
class Base {
|
|
803
|
-
constructor(init, next, stateToResult, onClose) {
|
|
804
|
-
this.init = init;
|
|
805
|
-
this.next = next;
|
|
806
|
-
this.stateToResult = stateToResult;
|
|
807
|
-
this.onClose = onClose;
|
|
808
|
-
}
|
|
809
|
-
filterInput(pred) {
|
|
810
|
-
return create(
|
|
811
|
-
async () => ({
|
|
812
|
-
nextIndex: 0,
|
|
813
|
-
state: await AsyncOptLazy.toMaybePromise(this.init)
|
|
814
|
-
}),
|
|
815
|
-
async (state, elem, index, halt) => {
|
|
816
|
-
if (pred(elem, index, halt)) {
|
|
817
|
-
state.state = await this.next(
|
|
818
|
-
state.state,
|
|
819
|
-
elem,
|
|
820
|
-
state.nextIndex++,
|
|
821
|
-
halt
|
|
822
|
-
);
|
|
823
|
-
}
|
|
824
|
-
return state;
|
|
825
|
-
},
|
|
826
|
-
(state) => this.stateToResult(state.state),
|
|
827
|
-
(state, error) => this.onClose?.(state.state, error)
|
|
828
|
-
);
|
|
829
|
-
}
|
|
830
|
-
mapInput(mapFun) {
|
|
831
|
-
return create(
|
|
832
|
-
this.init,
|
|
833
|
-
async (state, elem, index, halt) => this.next(state, await mapFun(elem, index), index, halt),
|
|
834
|
-
this.stateToResult,
|
|
835
|
-
this.onClose
|
|
836
|
-
);
|
|
837
|
-
}
|
|
838
|
-
collectInput(collectFun) {
|
|
839
|
-
return create(
|
|
840
|
-
async () => ({
|
|
841
|
-
nextIndex: 0,
|
|
842
|
-
state: await AsyncOptLazy.toMaybePromise(this.init)
|
|
843
|
-
}),
|
|
844
|
-
async (state, elem, index, halt) => {
|
|
845
|
-
const nextElem = await collectFun(elem, index, CollectFun.Skip, halt);
|
|
846
|
-
if (CollectFun.Skip !== nextElem) {
|
|
847
|
-
state.state = await this.next(
|
|
848
|
-
state.state,
|
|
849
|
-
nextElem,
|
|
850
|
-
state.nextIndex++,
|
|
851
|
-
halt
|
|
852
|
-
);
|
|
853
|
-
}
|
|
854
|
-
return state;
|
|
855
|
-
},
|
|
856
|
-
(state) => this.stateToResult(state.state),
|
|
857
|
-
(state, error) => this.onClose?.(state.state, error)
|
|
858
|
-
);
|
|
859
|
-
}
|
|
860
|
-
mapOutput(mapFun) {
|
|
861
|
-
return create(
|
|
862
|
-
this.init,
|
|
863
|
-
this.next,
|
|
864
|
-
async (state) => mapFun(await this.stateToResult(state)),
|
|
865
|
-
this.onClose
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
takeInput(amount) {
|
|
869
|
-
if (amount <= 0) {
|
|
870
|
-
return create(this.init, identity2, this.stateToResult);
|
|
871
|
-
}
|
|
872
|
-
return this.filterInput((_, i, halt) => {
|
|
873
|
-
const more = i < amount;
|
|
874
|
-
if (!more)
|
|
875
|
-
halt();
|
|
876
|
-
return more;
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
dropInput(amount) {
|
|
880
|
-
if (amount <= 0) {
|
|
881
|
-
return this;
|
|
882
|
-
}
|
|
883
|
-
return this.filterInput((_, i) => i >= amount);
|
|
884
|
-
}
|
|
885
|
-
sliceInput(from2 = 0, amount) {
|
|
886
|
-
if (void 0 === amount)
|
|
887
|
-
return this.dropInput(from2);
|
|
888
|
-
if (amount <= 0)
|
|
889
|
-
return create(this.init, identity2, this.stateToResult);
|
|
890
|
-
if (from2 <= 0)
|
|
891
|
-
return this.takeInput(amount);
|
|
892
|
-
return this.takeInput(amount).dropInput(from2);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
AsyncReducer2.Base = Base;
|
|
896
|
-
function create(init, next, stateToResult, onClose) {
|
|
897
|
-
return new AsyncReducer2.Base(
|
|
898
|
-
init,
|
|
899
|
-
next,
|
|
900
|
-
stateToResult,
|
|
901
|
-
onClose
|
|
902
|
-
);
|
|
903
|
-
}
|
|
904
|
-
AsyncReducer2.create = create;
|
|
905
|
-
function createMono(init, next, stateToResult, onClose) {
|
|
906
|
-
return create(init, next, stateToResult ?? identity2, onClose);
|
|
907
|
-
}
|
|
908
|
-
AsyncReducer2.createMono = createMono;
|
|
909
|
-
function createOutput(init, next, stateToResult, onClose) {
|
|
910
|
-
return create(init, next, stateToResult ?? identity2, onClose);
|
|
911
|
-
}
|
|
912
|
-
AsyncReducer2.createOutput = createOutput;
|
|
913
|
-
function from(reducer) {
|
|
914
|
-
return AsyncReducer2.create(
|
|
915
|
-
reducer.init,
|
|
916
|
-
reducer.next,
|
|
917
|
-
reducer.stateToResult
|
|
918
|
-
);
|
|
919
|
-
}
|
|
920
|
-
AsyncReducer2.from = from;
|
|
921
|
-
AsyncReducer2.sum = createMono(0, (state, next) => state + next);
|
|
922
|
-
AsyncReducer2.product = createMono(1, (state, next, _, halt) => {
|
|
923
|
-
if (0 === next)
|
|
924
|
-
halt();
|
|
925
|
-
return state * next;
|
|
926
|
-
});
|
|
927
|
-
AsyncReducer2.average = createMono(
|
|
928
|
-
0,
|
|
929
|
-
(avg, value, index) => avg + (value - avg) / (index + 1)
|
|
930
|
-
);
|
|
931
|
-
AsyncReducer2.minBy = (compFun, otherwise) => {
|
|
932
|
-
const token = Symbol();
|
|
933
|
-
return create(
|
|
934
|
-
token,
|
|
935
|
-
async (state, next) => {
|
|
936
|
-
if (token === state)
|
|
937
|
-
return next;
|
|
938
|
-
return await compFun(state, next) < 0 ? state : next;
|
|
939
|
-
},
|
|
940
|
-
(state) => token === state ? AsyncOptLazy.toMaybePromise(otherwise) : state
|
|
941
|
-
);
|
|
942
|
-
};
|
|
943
|
-
AsyncReducer2.min = (otherwise) => {
|
|
944
|
-
return create(
|
|
945
|
-
void 0,
|
|
946
|
-
(state, next) => void 0 !== state && state < next ? state : next,
|
|
947
|
-
(state) => state ?? AsyncOptLazy.toMaybePromise(otherwise)
|
|
948
|
-
);
|
|
949
|
-
};
|
|
950
|
-
AsyncReducer2.maxBy = (compFun, otherwise) => {
|
|
951
|
-
const token = Symbol();
|
|
952
|
-
return create(
|
|
953
|
-
token,
|
|
954
|
-
async (state, next) => {
|
|
955
|
-
if (token === state)
|
|
956
|
-
return next;
|
|
957
|
-
return await compFun(state, next) > 0 ? state : next;
|
|
958
|
-
},
|
|
959
|
-
(state) => token === state ? AsyncOptLazy.toMaybePromise(otherwise) : state
|
|
960
|
-
);
|
|
961
|
-
};
|
|
962
|
-
AsyncReducer2.max = (otherwise) => {
|
|
963
|
-
return create(
|
|
964
|
-
void 0,
|
|
965
|
-
(state, next) => void 0 !== state && state > next ? state : next,
|
|
966
|
-
(state) => state ?? AsyncOptLazy.toMaybePromise(otherwise)
|
|
967
|
-
);
|
|
968
|
-
};
|
|
969
|
-
function join({
|
|
970
|
-
sep = "",
|
|
971
|
-
start = "",
|
|
972
|
-
end = "",
|
|
973
|
-
valueToString = String
|
|
974
|
-
} = {}) {
|
|
975
|
-
let curSep = "";
|
|
976
|
-
let curStart = start;
|
|
977
|
-
return create(
|
|
978
|
-
"",
|
|
979
|
-
(state, next) => {
|
|
980
|
-
const result = curStart.concat(state, curSep, valueToString(next));
|
|
981
|
-
curSep = sep;
|
|
982
|
-
curStart = "";
|
|
983
|
-
return result;
|
|
984
|
-
},
|
|
985
|
-
(state) => state.concat(end)
|
|
986
|
-
);
|
|
987
|
-
}
|
|
988
|
-
AsyncReducer2.join = join;
|
|
989
|
-
AsyncReducer2.count = (pred) => {
|
|
990
|
-
if (void 0 === pred)
|
|
991
|
-
return createOutput(0, (_, __, i) => i + 1);
|
|
992
|
-
return createOutput(0, async (state, next, i) => {
|
|
993
|
-
if (await pred?.(next, i))
|
|
994
|
-
return state + 1;
|
|
995
|
-
return state;
|
|
996
|
-
});
|
|
997
|
-
};
|
|
998
|
-
AsyncReducer2.firstWhere = (pred, otherwise) => {
|
|
999
|
-
const token = Symbol();
|
|
1000
|
-
return create(
|
|
1001
|
-
token,
|
|
1002
|
-
async (state, next, i, halt) => {
|
|
1003
|
-
if (token === state && await pred(next, i)) {
|
|
1004
|
-
halt();
|
|
1005
|
-
return next;
|
|
1006
|
-
}
|
|
1007
|
-
return state;
|
|
1008
|
-
},
|
|
1009
|
-
(state) => token === state ? AsyncOptLazy.toMaybePromise(otherwise) : state
|
|
1010
|
-
);
|
|
1011
|
-
};
|
|
1012
|
-
AsyncReducer2.first = (otherwise) => {
|
|
1013
|
-
const token = Symbol();
|
|
1014
|
-
return create(
|
|
1015
|
-
token,
|
|
1016
|
-
(state, next, _, halt) => {
|
|
1017
|
-
halt();
|
|
1018
|
-
if (token === state)
|
|
1019
|
-
return next;
|
|
1020
|
-
return state;
|
|
1021
|
-
},
|
|
1022
|
-
(state) => token === state ? AsyncOptLazy.toMaybePromise(otherwise) : state
|
|
1023
|
-
);
|
|
1024
|
-
};
|
|
1025
|
-
AsyncReducer2.lastWhere = (pred, otherwise) => {
|
|
1026
|
-
const token = Symbol();
|
|
1027
|
-
return create(
|
|
1028
|
-
token,
|
|
1029
|
-
async (state, next, i) => {
|
|
1030
|
-
if (await pred(next, i))
|
|
1031
|
-
return next;
|
|
1032
|
-
return state;
|
|
1033
|
-
},
|
|
1034
|
-
(state) => token === state ? AsyncOptLazy.toMaybePromise(otherwise) : state
|
|
1035
|
-
);
|
|
1036
|
-
};
|
|
1037
|
-
AsyncReducer2.last = (otherwise) => {
|
|
1038
|
-
const token = Symbol();
|
|
1039
|
-
return create(
|
|
1040
|
-
() => token,
|
|
1041
|
-
(_, next) => next,
|
|
1042
|
-
(state) => token === state ? AsyncOptLazy.toMaybePromise(otherwise) : state
|
|
1043
|
-
);
|
|
1044
|
-
};
|
|
1045
|
-
function some(pred) {
|
|
1046
|
-
return createOutput(
|
|
1047
|
-
false,
|
|
1048
|
-
async (state, next, i, halt) => {
|
|
1049
|
-
if (state)
|
|
1050
|
-
return state;
|
|
1051
|
-
const satisfies = await pred(next, i);
|
|
1052
|
-
if (satisfies) {
|
|
1053
|
-
halt();
|
|
1054
|
-
}
|
|
1055
|
-
return satisfies;
|
|
1056
|
-
}
|
|
1057
|
-
);
|
|
1058
|
-
}
|
|
1059
|
-
AsyncReducer2.some = some;
|
|
1060
|
-
function every(pred) {
|
|
1061
|
-
return createOutput(
|
|
1062
|
-
true,
|
|
1063
|
-
async (state, next, i, halt) => {
|
|
1064
|
-
if (!state)
|
|
1065
|
-
return state;
|
|
1066
|
-
const satisfies = await pred(next, i);
|
|
1067
|
-
if (!satisfies) {
|
|
1068
|
-
halt();
|
|
1069
|
-
}
|
|
1070
|
-
return satisfies;
|
|
1071
|
-
}
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
1074
|
-
AsyncReducer2.every = every;
|
|
1075
|
-
function contains(elem, eq = Object.is) {
|
|
1076
|
-
return createOutput(false, (state, next, _, halt) => {
|
|
1077
|
-
if (state)
|
|
1078
|
-
return state;
|
|
1079
|
-
const satisfies = eq(next, elem);
|
|
1080
|
-
if (satisfies) {
|
|
1081
|
-
halt();
|
|
1082
|
-
}
|
|
1083
|
-
return satisfies;
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
AsyncReducer2.contains = contains;
|
|
1087
|
-
AsyncReducer2.and = createMono(true, (state, next, _, halt) => {
|
|
1088
|
-
if (!state)
|
|
1089
|
-
return state;
|
|
1090
|
-
if (!next)
|
|
1091
|
-
halt();
|
|
1092
|
-
return next;
|
|
1093
|
-
});
|
|
1094
|
-
AsyncReducer2.or = createMono(false, (state, next, _, halt) => {
|
|
1095
|
-
if (state)
|
|
1096
|
-
return state;
|
|
1097
|
-
if (next)
|
|
1098
|
-
halt();
|
|
1099
|
-
return next;
|
|
1100
|
-
});
|
|
1101
|
-
AsyncReducer2.isEmpty = createOutput(
|
|
1102
|
-
true,
|
|
1103
|
-
(_, __, ___, halt) => {
|
|
1104
|
-
halt();
|
|
1105
|
-
return false;
|
|
1106
|
-
}
|
|
1107
|
-
);
|
|
1108
|
-
AsyncReducer2.nonEmpty = createOutput(
|
|
1109
|
-
false,
|
|
1110
|
-
(_, __, ___, halt) => {
|
|
1111
|
-
halt();
|
|
1112
|
-
return true;
|
|
1113
|
-
}
|
|
1114
|
-
);
|
|
1115
|
-
function toArray() {
|
|
1116
|
-
return create(
|
|
1117
|
-
() => [],
|
|
1118
|
-
(state, next) => {
|
|
1119
|
-
state.push(next);
|
|
1120
|
-
return state;
|
|
1121
|
-
},
|
|
1122
|
-
(state) => state.slice()
|
|
1123
|
-
);
|
|
1124
|
-
}
|
|
1125
|
-
AsyncReducer2.toArray = toArray;
|
|
1126
|
-
function toJSMap() {
|
|
1127
|
-
return create(
|
|
1128
|
-
() => /* @__PURE__ */ new Map(),
|
|
1129
|
-
(state, next) => {
|
|
1130
|
-
state.set(next[0], next[1]);
|
|
1131
|
-
return state;
|
|
1132
|
-
},
|
|
1133
|
-
(s) => new Map(s)
|
|
1134
|
-
);
|
|
1135
|
-
}
|
|
1136
|
-
AsyncReducer2.toJSMap = toJSMap;
|
|
1137
|
-
function toJSSet() {
|
|
1138
|
-
return create(
|
|
1139
|
-
() => /* @__PURE__ */ new Set(),
|
|
1140
|
-
(state, next) => {
|
|
1141
|
-
state.add(next);
|
|
1142
|
-
return state;
|
|
1143
|
-
},
|
|
1144
|
-
(s) => new Set(s)
|
|
1145
|
-
);
|
|
1146
|
-
}
|
|
1147
|
-
AsyncReducer2.toJSSet = toJSSet;
|
|
1148
|
-
function toJSObject() {
|
|
1149
|
-
return create(
|
|
1150
|
-
() => ({}),
|
|
1151
|
-
(state, entry) => {
|
|
1152
|
-
state[entry[0]] = entry[1];
|
|
1153
|
-
return state;
|
|
1154
|
-
},
|
|
1155
|
-
(s) => ({ ...s })
|
|
1156
|
-
);
|
|
1157
|
-
}
|
|
1158
|
-
AsyncReducer2.toJSObject = toJSObject;
|
|
1159
|
-
function combineArr(...reducers) {
|
|
1160
|
-
const createState = () => {
|
|
1161
|
-
return Promise.all(
|
|
1162
|
-
reducers.map(async (reducer) => {
|
|
1163
|
-
const result = {
|
|
1164
|
-
reducer,
|
|
1165
|
-
halted: false,
|
|
1166
|
-
halt() {
|
|
1167
|
-
result.halted = true;
|
|
1168
|
-
},
|
|
1169
|
-
state: await AsyncOptLazy.toMaybePromise(reducer.init)
|
|
1170
|
-
};
|
|
1171
|
-
return result;
|
|
1172
|
-
})
|
|
1173
|
-
);
|
|
1174
|
-
};
|
|
1175
|
-
return create(
|
|
1176
|
-
createState,
|
|
1177
|
-
async (allState, next, index, halt) => {
|
|
1178
|
-
let anyNotHalted = false;
|
|
1179
|
-
await Promise.all(
|
|
1180
|
-
allState.map(async (red) => {
|
|
1181
|
-
if (red.halted)
|
|
1182
|
-
return;
|
|
1183
|
-
red.state = await red.reducer.next(
|
|
1184
|
-
red.state,
|
|
1185
|
-
next,
|
|
1186
|
-
index,
|
|
1187
|
-
red.halt
|
|
1188
|
-
);
|
|
1189
|
-
if (!red.halted)
|
|
1190
|
-
anyNotHalted = true;
|
|
1191
|
-
})
|
|
1192
|
-
);
|
|
1193
|
-
if (!anyNotHalted)
|
|
1194
|
-
halt();
|
|
1195
|
-
return allState;
|
|
1196
|
-
},
|
|
1197
|
-
(allState) => Promise.all(
|
|
1198
|
-
allState.map((st) => st.reducer.stateToResult(st.state))
|
|
1199
|
-
)
|
|
1200
|
-
);
|
|
1201
|
-
}
|
|
1202
|
-
AsyncReducer2.combineArr = combineArr;
|
|
1203
|
-
function combineObj(reducerObj) {
|
|
1204
|
-
const createState = async () => {
|
|
1205
|
-
const entries = await Promise.all(
|
|
1206
|
-
Object.entries(reducerObj).map(async ([key, reducer]) => {
|
|
1207
|
-
const result = {
|
|
1208
|
-
reducer,
|
|
1209
|
-
halted: false,
|
|
1210
|
-
halt() {
|
|
1211
|
-
result.halted = true;
|
|
1212
|
-
},
|
|
1213
|
-
state: await AsyncOptLazy.toMaybePromise(reducer.init)
|
|
1214
|
-
};
|
|
1215
|
-
return [key, result];
|
|
1216
|
-
})
|
|
1217
|
-
);
|
|
1218
|
-
return Object.fromEntries(entries);
|
|
1219
|
-
};
|
|
1220
|
-
return create(
|
|
1221
|
-
createState,
|
|
1222
|
-
async (allState, next, index, halt) => {
|
|
1223
|
-
let anyNotHalted = false;
|
|
1224
|
-
await Promise.all(
|
|
1225
|
-
Object.values(allState).map(async (red) => {
|
|
1226
|
-
if (red.halted) {
|
|
1227
|
-
return;
|
|
1228
|
-
}
|
|
1229
|
-
red.state = await red.reducer.next(
|
|
1230
|
-
red.state,
|
|
1231
|
-
next,
|
|
1232
|
-
index,
|
|
1233
|
-
red.halt
|
|
1234
|
-
);
|
|
1235
|
-
if (!red.halted) {
|
|
1236
|
-
anyNotHalted = true;
|
|
1237
|
-
}
|
|
1238
|
-
})
|
|
1239
|
-
);
|
|
1240
|
-
if (!anyNotHalted) {
|
|
1241
|
-
halt();
|
|
1242
|
-
}
|
|
1243
|
-
return allState;
|
|
1244
|
-
},
|
|
1245
|
-
async (allState) => {
|
|
1246
|
-
const entries = await Promise.all(
|
|
1247
|
-
Object.entries(allState).map(
|
|
1248
|
-
async ([key, st]) => [key, await st.reducer.stateToResult(st.state)]
|
|
1249
|
-
)
|
|
1250
|
-
);
|
|
1251
|
-
return Object.fromEntries(entries);
|
|
1252
|
-
}
|
|
1253
|
-
);
|
|
1254
|
-
}
|
|
1255
|
-
AsyncReducer2.combineObj = combineObj;
|
|
1256
|
-
})(AsyncReducer || (AsyncReducer = {}));
|
|
1257
|
-
|
|
1258
368
|
// src/comp.mts
|
|
1259
369
|
var Comp;
|
|
1260
370
|
((Comp2) => {
|