silentium 0.0.223 → 0.0.224
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/CHANGELOG.md +2 -0
- package/dist/silentium.cjs +131 -103
- package/dist/silentium.cjs.map +1 -1
- package/dist/silentium.d.ts +1 -0
- package/dist/silentium.js +131 -103
- package/dist/silentium.js.map +1 -1
- package/dist/silentium.min.js +1 -1
- package/dist/silentium.min.mjs +1 -1
- package/dist/silentium.min.mjs.map +1 -1
- package/dist/silentium.mjs +131 -103
- package/dist/silentium.mjs.map +1 -1
- package/eslint.config.mjs +10 -0
- package/package.json +2 -1
- package/src/base/Connected.ts +2 -2
- package/src/base/DestroyContainer.ts +6 -3
- package/src/base/Local.ts +2 -2
- package/src/base/Locals.ts +3 -1
- package/src/base/Message.test.ts +1 -1
- package/src/base/Message.ts +1 -1
- package/src/base/Rejections.ts +16 -11
- package/src/base/Silence.ts +1 -1
- package/src/base/Source.ts +3 -2
- package/src/base/SourceComputed.ts +6 -2
- package/src/components/All.ts +2 -2
- package/src/components/Any.ts +1 -1
- package/src/components/Applied.ts +1 -1
- package/src/components/Catch.ts +1 -1
- package/src/components/Chain.ts +1 -1
- package/src/components/Context.ts +7 -6
- package/src/components/ContextChain.ts +1 -1
- package/src/components/ContextOf.ts +1 -1
- package/src/components/Default.ts +1 -1
- package/src/components/Empty.ts +2 -2
- package/src/components/ExecutorApplied.ts +1 -1
- package/src/components/Filtered.ts +1 -1
- package/src/components/Fold.ts +3 -1
- package/src/components/Freeze.ts +2 -2
- package/src/components/FromEvent.ts +14 -12
- package/src/components/Late.ts +11 -9
- package/src/components/Lazy.ts +2 -2
- package/src/components/Map.test.ts +1 -1
- package/src/components/Map.ts +3 -3
- package/src/components/Once.ts +2 -2
- package/src/components/Piped.ts +1 -1
- package/src/components/Primitive.ts +3 -2
- package/src/components/Process.ts +3 -3
- package/src/components/Promisify.ts +1 -1
- package/src/components/Race.ts +3 -3
- package/src/components/Sequence.ts +2 -2
- package/src/components/Shared.ts +12 -10
- package/src/components/Stream.ts +3 -3
- package/src/components/Trackable.ts +1 -1
- package/src/helpers/DevTools.ts +8 -3
- package/src/testing/wait.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.224](https://github.com/silentium-lab/silentium/compare/v0.0.223...v0.0.224) (2026-04-02)
|
|
6
|
+
|
|
5
7
|
### [0.0.223](https://github.com/silentium-lab/silentium/compare/v0.0.222...v0.0.223) (2026-04-01)
|
|
6
8
|
|
|
7
9
|
|
package/dist/silentium.cjs
CHANGED
|
@@ -60,14 +60,17 @@ class DestroyContainerImpl {
|
|
|
60
60
|
* @returns
|
|
61
61
|
*/
|
|
62
62
|
many(destroyableList) {
|
|
63
|
-
|
|
63
|
+
const destroyMany = (d) => {
|
|
64
64
|
this.add(d);
|
|
65
|
-
}
|
|
65
|
+
};
|
|
66
|
+
destroyableList.forEach(destroyMany);
|
|
66
67
|
return this;
|
|
67
68
|
}
|
|
68
69
|
destroy() {
|
|
69
70
|
this._destroyed = true;
|
|
70
|
-
this.destructors.forEach((d)
|
|
71
|
+
this.destructors.forEach(function dcDestroy(d) {
|
|
72
|
+
d.destroy();
|
|
73
|
+
});
|
|
71
74
|
this.destructors.length = 0;
|
|
72
75
|
return this;
|
|
73
76
|
}
|
|
@@ -89,9 +92,10 @@ const _RejectionsImpl = class _RejectionsImpl {
|
|
|
89
92
|
constructor() {
|
|
90
93
|
__publicField$5(this, "catchers", []);
|
|
91
94
|
__publicField$5(this, "lastRejectReason", null);
|
|
92
|
-
__publicField$5(this, "reject"
|
|
95
|
+
__publicField$5(this, "reject");
|
|
96
|
+
const rejectionsRejectHandler = (reason) => {
|
|
93
97
|
this.lastRejectReason = reason;
|
|
94
|
-
this.catchers.forEach((catcher)
|
|
98
|
+
this.catchers.forEach(function rejectionsRejectCatchers(catcher) {
|
|
95
99
|
catcher(reason);
|
|
96
100
|
});
|
|
97
101
|
if (_RejectionsImpl.globalCatch) {
|
|
@@ -99,7 +103,8 @@ const _RejectionsImpl = class _RejectionsImpl {
|
|
|
99
103
|
} else if (this.catchers.length === 0) {
|
|
100
104
|
console.error(["Unhandled Message Rejection:", reason].join(" "));
|
|
101
105
|
}
|
|
102
|
-
}
|
|
106
|
+
};
|
|
107
|
+
this.reject = rejectionsRejectHandler;
|
|
103
108
|
}
|
|
104
109
|
catch(rejected) {
|
|
105
110
|
if (this.lastRejectReason !== null) {
|
|
@@ -130,9 +135,10 @@ class PrimitiveImpl {
|
|
|
130
135
|
}
|
|
131
136
|
ensureTouched() {
|
|
132
137
|
if (!this.touched) {
|
|
133
|
-
|
|
138
|
+
const primitiveBaseSub = (v) => {
|
|
134
139
|
this.theValue = v;
|
|
135
|
-
}
|
|
140
|
+
};
|
|
141
|
+
this.$base.then(primitiveBaseSub);
|
|
136
142
|
}
|
|
137
143
|
this.touched = true;
|
|
138
144
|
}
|
|
@@ -156,7 +162,7 @@ class PrimitiveImpl {
|
|
|
156
162
|
const ResetSilenceCache = Symbol("reset-silence-cache");
|
|
157
163
|
function Silence(resolve) {
|
|
158
164
|
let lastValue;
|
|
159
|
-
return (v)
|
|
165
|
+
return function SilenceImpl(v) {
|
|
160
166
|
if (v === ResetSilenceCache) {
|
|
161
167
|
lastValue = void 0;
|
|
162
168
|
v = void 0;
|
|
@@ -229,7 +235,7 @@ class MessageImpl {
|
|
|
229
235
|
this.dc.add(newMessage);
|
|
230
236
|
try {
|
|
231
237
|
const mbDestructor = this.executor(
|
|
232
|
-
Silence((value)
|
|
238
|
+
Silence(function messageResolver(value) {
|
|
233
239
|
if (!newMessageDc.destroyed()) {
|
|
234
240
|
resolve(value);
|
|
235
241
|
}
|
|
@@ -282,9 +288,9 @@ function Connected(main, ...m) {
|
|
|
282
288
|
const dc = DestroyContainer();
|
|
283
289
|
dc.add(main);
|
|
284
290
|
dc.many(m);
|
|
285
|
-
return Message((resolve, reject)
|
|
291
|
+
return Message(function ConnectedImpl(resolve, reject) {
|
|
286
292
|
main.catch(reject).then(resolve);
|
|
287
|
-
m.forEach((other)
|
|
293
|
+
m.forEach(function connectedMessagesForEach(other) {
|
|
288
294
|
if (isMessage(other)) {
|
|
289
295
|
other.catch(reject);
|
|
290
296
|
}
|
|
@@ -297,20 +303,22 @@ function Local(_base) {
|
|
|
297
303
|
const $base = Actual(_base);
|
|
298
304
|
return Message(function LocalImpl(resolve, reject) {
|
|
299
305
|
let destroyed = false;
|
|
300
|
-
$base.then((v)
|
|
306
|
+
$base.then(function localBaseSub(v) {
|
|
301
307
|
if (!destroyed) {
|
|
302
308
|
resolve(v);
|
|
303
309
|
}
|
|
304
310
|
});
|
|
305
311
|
$base.catch(reject);
|
|
306
|
-
return ()
|
|
312
|
+
return function localDestructor() {
|
|
307
313
|
destroyed = true;
|
|
308
314
|
};
|
|
309
315
|
});
|
|
310
316
|
}
|
|
311
317
|
|
|
312
318
|
function Props(...messages) {
|
|
313
|
-
return messages.map((m)
|
|
319
|
+
return messages.map(function propsMap(m) {
|
|
320
|
+
return Local(m);
|
|
321
|
+
});
|
|
314
322
|
}
|
|
315
323
|
|
|
316
324
|
function New(construct) {
|
|
@@ -335,9 +343,10 @@ class SourceImpl {
|
|
|
335
343
|
}
|
|
336
344
|
use(value) {
|
|
337
345
|
if (!this.message.destroyed()) {
|
|
338
|
-
|
|
346
|
+
const sourceSilenceUse = (v) => {
|
|
339
347
|
this.sourceExecutor(v);
|
|
340
|
-
}
|
|
348
|
+
};
|
|
349
|
+
this.silenceUse.use(value, sourceSilenceUse);
|
|
341
350
|
}
|
|
342
351
|
return this;
|
|
343
352
|
}
|
|
@@ -361,8 +370,12 @@ class SourceImpl {
|
|
|
361
370
|
|
|
362
371
|
function SourceComputed(message, source) {
|
|
363
372
|
return Source(
|
|
364
|
-
(resolve, reject)
|
|
365
|
-
|
|
373
|
+
function sourceComputedMsgExecutor(resolve, reject) {
|
|
374
|
+
return message.then(resolve).catch(reject);
|
|
375
|
+
},
|
|
376
|
+
function sourceComputedSrcExecutor(v) {
|
|
377
|
+
source.use(v);
|
|
378
|
+
}
|
|
366
379
|
);
|
|
367
380
|
}
|
|
368
381
|
|
|
@@ -384,9 +397,9 @@ function All(...messages) {
|
|
|
384
397
|
resolve([]);
|
|
385
398
|
return;
|
|
386
399
|
}
|
|
387
|
-
$messages.map((m, key)
|
|
400
|
+
$messages.map(function allMessagesMap(m, key) {
|
|
388
401
|
m.catch(reject);
|
|
389
|
-
m.then((v)
|
|
402
|
+
m.then(function allMessageSub(v) {
|
|
390
403
|
filled.add(key.toString());
|
|
391
404
|
result[key] = v;
|
|
392
405
|
if (isAllFilled(filled, known)) {
|
|
@@ -400,7 +413,7 @@ function All(...messages) {
|
|
|
400
413
|
function Any(...messages) {
|
|
401
414
|
const $messages = messages.map(Actual);
|
|
402
415
|
return Message(function AnyImpl(resolve, reject) {
|
|
403
|
-
$messages.forEach((message)
|
|
416
|
+
$messages.forEach(function anyMessagesSub(message) {
|
|
404
417
|
message.catch(reject);
|
|
405
418
|
message.then(resolve);
|
|
406
419
|
});
|
|
@@ -412,7 +425,7 @@ function Applied(base, applier) {
|
|
|
412
425
|
return Message(function AppliedImpl(resolve, reject) {
|
|
413
426
|
const dc = DestroyContainer();
|
|
414
427
|
$base.catch(reject);
|
|
415
|
-
$base.then((v)
|
|
428
|
+
$base.then(function appliedBaseSub(v) {
|
|
416
429
|
const result = applier(v);
|
|
417
430
|
if (isMessage(result)) {
|
|
418
431
|
dc.destroy();
|
|
@@ -434,12 +447,12 @@ function Shared($base) {
|
|
|
434
447
|
class SharedImpl {
|
|
435
448
|
constructor($base) {
|
|
436
449
|
this.$base = $base;
|
|
437
|
-
__publicField$1(this, "resolver", (v)
|
|
450
|
+
__publicField$1(this, "resolver", function sharedImplResolver(v) {
|
|
438
451
|
this.lastV = v;
|
|
439
|
-
this.resolvers.forEach((r)
|
|
452
|
+
this.resolvers.forEach(function sharedImplResolversForEach(r) {
|
|
440
453
|
r(v);
|
|
441
454
|
});
|
|
442
|
-
});
|
|
455
|
+
}.bind(this));
|
|
443
456
|
__publicField$1(this, "lastV");
|
|
444
457
|
__publicField$1(this, "resolvers", /* @__PURE__ */ new Set());
|
|
445
458
|
__publicField$1(this, "source");
|
|
@@ -451,30 +464,32 @@ class SharedImpl {
|
|
|
451
464
|
this.silenceUse = SilenceUse(this);
|
|
452
465
|
}
|
|
453
466
|
then(resolved, rejected) {
|
|
454
|
-
const
|
|
467
|
+
const sharedMsgExecutor = (res, rej) => {
|
|
455
468
|
this.resolvers.add(res);
|
|
456
469
|
if (this.resolvers.size === 1) {
|
|
457
470
|
this.$base.then(this.resolver, rej);
|
|
458
471
|
} else if (isFilled(this.lastV)) {
|
|
459
472
|
res(this.lastV);
|
|
460
473
|
}
|
|
461
|
-
return ()
|
|
474
|
+
return function sharedMsgDestructor() {
|
|
462
475
|
this.resolvers.delete(res);
|
|
463
|
-
};
|
|
464
|
-
}
|
|
476
|
+
}.bind(this);
|
|
477
|
+
};
|
|
478
|
+
const msg$ = Message(sharedMsgExecutor).then(resolved);
|
|
465
479
|
if (rejected) {
|
|
466
480
|
msg$.catch(rejected);
|
|
467
481
|
}
|
|
468
482
|
return msg$;
|
|
469
483
|
}
|
|
470
484
|
use(value) {
|
|
471
|
-
|
|
485
|
+
const sharedUse = (v) => {
|
|
472
486
|
if (this.source) {
|
|
473
487
|
this.source.use(v);
|
|
474
488
|
} else {
|
|
475
489
|
this.resolver(v);
|
|
476
490
|
}
|
|
477
|
-
}
|
|
491
|
+
};
|
|
492
|
+
this.silenceUse.use(value, sharedUse);
|
|
478
493
|
return this;
|
|
479
494
|
}
|
|
480
495
|
catch(rejected) {
|
|
@@ -512,21 +527,22 @@ class LateImpl {
|
|
|
512
527
|
this.v = v;
|
|
513
528
|
__publicField(this, "rejections", Rejections());
|
|
514
529
|
__publicField(this, "lateR", null);
|
|
515
|
-
__publicField(this, "notify", () => {
|
|
516
|
-
if (isFilled(this.v) && this.lateR) {
|
|
517
|
-
try {
|
|
518
|
-
this.lateR(this.v);
|
|
519
|
-
} catch (e) {
|
|
520
|
-
this.rejections.reject(e);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
530
|
__publicField(this, "silenceUse");
|
|
525
|
-
|
|
526
|
-
|
|
531
|
+
const silenceUseExecutor = (resolve) => {
|
|
532
|
+
if (this.v !== void 0) {
|
|
527
533
|
resolve(this.v);
|
|
528
|
-
}
|
|
529
|
-
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
this.silenceUse = SilenceUse(Message(silenceUseExecutor));
|
|
537
|
+
}
|
|
538
|
+
notify() {
|
|
539
|
+
if (isFilled(this.v) && this.lateR) {
|
|
540
|
+
try {
|
|
541
|
+
this.lateR(this.v);
|
|
542
|
+
} catch (e) {
|
|
543
|
+
this.rejections.reject(e);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
530
546
|
}
|
|
531
547
|
then(r) {
|
|
532
548
|
if (this.lateR) {
|
|
@@ -539,10 +555,11 @@ class LateImpl {
|
|
|
539
555
|
return this;
|
|
540
556
|
}
|
|
541
557
|
use(value) {
|
|
542
|
-
|
|
558
|
+
const silenceUseLateExecutor = (v) => {
|
|
543
559
|
this.v = v;
|
|
544
560
|
this.notify();
|
|
545
|
-
}
|
|
561
|
+
};
|
|
562
|
+
this.silenceUse.use(value, silenceUseLateExecutor);
|
|
546
563
|
return this;
|
|
547
564
|
}
|
|
548
565
|
catch(rejected) {
|
|
@@ -563,7 +580,7 @@ function Catch($base) {
|
|
|
563
580
|
const rejections = Rejections();
|
|
564
581
|
$base.catch(rejections.reject);
|
|
565
582
|
const $error = Late();
|
|
566
|
-
rejections.catch((e)
|
|
583
|
+
rejections.catch(function catchErrorSub(e) {
|
|
567
584
|
$error.use(e);
|
|
568
585
|
});
|
|
569
586
|
return $error;
|
|
@@ -578,7 +595,7 @@ function Chain(...messages) {
|
|
|
578
595
|
const message = $messages[index];
|
|
579
596
|
message.catch(reject);
|
|
580
597
|
const next = $messages[index + 1];
|
|
581
|
-
message.then((v)
|
|
598
|
+
message.then(function chainMessageSub(v) {
|
|
582
599
|
oneMessage(v, next, index);
|
|
583
600
|
});
|
|
584
601
|
};
|
|
@@ -612,16 +629,18 @@ Context.transport = /* @__PURE__ */ new Map();
|
|
|
612
629
|
function Context(name, params = {}) {
|
|
613
630
|
const $msg = Destructured(
|
|
614
631
|
All(Actual(name), Actual(params)),
|
|
615
|
-
(name2, params2)
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
632
|
+
function contextMsgNormalize(name2, params2) {
|
|
633
|
+
return {
|
|
634
|
+
transport: name2,
|
|
635
|
+
params: params2,
|
|
636
|
+
result: void 0,
|
|
637
|
+
error: void 0
|
|
638
|
+
};
|
|
639
|
+
}
|
|
621
640
|
);
|
|
622
641
|
return Source(
|
|
623
|
-
(resolve, reject)
|
|
624
|
-
$msg.then((message)
|
|
642
|
+
function contextMsgImpl(resolve, reject) {
|
|
643
|
+
$msg.then(function contextMsgSub(message) {
|
|
625
644
|
const transport = Context.transport.get(message.transport);
|
|
626
645
|
if (transport === void 0) {
|
|
627
646
|
throw new Error(`Context: unknown transport ${message.transport}`);
|
|
@@ -639,7 +658,7 @@ function Context(name, params = {}) {
|
|
|
639
658
|
}
|
|
640
659
|
});
|
|
641
660
|
},
|
|
642
|
-
(value)
|
|
661
|
+
function contextSrcImpl(value) {
|
|
643
662
|
const msg = Primitive($msg).primitive();
|
|
644
663
|
if (msg === null) {
|
|
645
664
|
throw new Error("Context: sourcing impossible message not existed");
|
|
@@ -658,7 +677,7 @@ function Context(name, params = {}) {
|
|
|
658
677
|
|
|
659
678
|
function ContextChain(base) {
|
|
660
679
|
const $base = Actual(base);
|
|
661
|
-
return (context)
|
|
680
|
+
return function contextChainHandler(context) {
|
|
662
681
|
if (context.value && isSource(base)) {
|
|
663
682
|
base.use(context.value);
|
|
664
683
|
return;
|
|
@@ -673,7 +692,7 @@ function ContextChain(base) {
|
|
|
673
692
|
function ContextOf(transport) {
|
|
674
693
|
const $msg = Late();
|
|
675
694
|
Context.transport.set(transport, $msg.use.bind($msg));
|
|
676
|
-
return Message((resolve, reject)
|
|
695
|
+
return Message(function contextOfImpl(resolve, reject) {
|
|
677
696
|
$msg.catch(reject);
|
|
678
697
|
$msg.then(resolve);
|
|
679
698
|
});
|
|
@@ -682,21 +701,21 @@ function ContextOf(transport) {
|
|
|
682
701
|
function Default($base, _default) {
|
|
683
702
|
const $default = Actual(_default);
|
|
684
703
|
const $defaultAfterError = Applied(Catch($base), () => $default);
|
|
685
|
-
return Message((resolve)
|
|
704
|
+
return Message(function DefaultImpl(resolve) {
|
|
686
705
|
$base.then(resolve);
|
|
687
706
|
$defaultAfterError.then(resolve);
|
|
688
707
|
});
|
|
689
708
|
}
|
|
690
709
|
|
|
691
710
|
function Empty($base, after) {
|
|
692
|
-
return Message((resolve, reject)
|
|
711
|
+
return Message(function EmptyImpl(resolve, reject) {
|
|
693
712
|
const p = Primitive($base);
|
|
694
713
|
try {
|
|
695
714
|
$base.then(resolve).catch(reject);
|
|
696
715
|
if (!after) {
|
|
697
716
|
p.primitiveWithException();
|
|
698
717
|
}
|
|
699
|
-
after?.then(()
|
|
718
|
+
after?.then(function emptyAfterSub() {
|
|
700
719
|
try {
|
|
701
720
|
p.primitiveWithException();
|
|
702
721
|
} catch {
|
|
@@ -713,7 +732,7 @@ function ExecutorApplied($base, applier) {
|
|
|
713
732
|
return Message(function ExecutorAppliedImpl(resolve, reject) {
|
|
714
733
|
$base.catch(reject);
|
|
715
734
|
const sub = Destroyable($base.then(applier(resolve)));
|
|
716
|
-
return ()
|
|
735
|
+
return function executorAppliedDestroy() {
|
|
717
736
|
sub.destroy();
|
|
718
737
|
};
|
|
719
738
|
});
|
|
@@ -723,7 +742,7 @@ function Filtered(base, predicate, defaultValue) {
|
|
|
723
742
|
const $base = Actual(base);
|
|
724
743
|
return Message(function FilteredImpl(resolve, reject) {
|
|
725
744
|
$base.catch(reject);
|
|
726
|
-
$base.then((v)
|
|
745
|
+
$base.then(function filteredBaseSub(v) {
|
|
727
746
|
if (predicate(v)) {
|
|
728
747
|
resolve(v);
|
|
729
748
|
} else if (defaultValue !== void 0) {
|
|
@@ -737,7 +756,9 @@ function Fold(data, reducer, initial) {
|
|
|
737
756
|
const $data = Actual(data);
|
|
738
757
|
const $initial = Actual(initial);
|
|
739
758
|
return Computed(
|
|
740
|
-
(data2, initial2)
|
|
759
|
+
function foldComputed(data2, initial2) {
|
|
760
|
+
return data2.reduce(reducer, initial2);
|
|
761
|
+
},
|
|
741
762
|
$data,
|
|
742
763
|
$initial
|
|
743
764
|
);
|
|
@@ -747,13 +768,13 @@ function Freeze($base, $invalidate) {
|
|
|
747
768
|
let freezedValue = null;
|
|
748
769
|
return Message(function FreezeImpl(resolve, reject) {
|
|
749
770
|
$base.catch(reject);
|
|
750
|
-
$base.then((v)
|
|
771
|
+
$base.then(function freezeBaseSub(v) {
|
|
751
772
|
if (freezedValue === null) {
|
|
752
773
|
freezedValue = v;
|
|
753
774
|
}
|
|
754
775
|
resolve(freezedValue);
|
|
755
776
|
});
|
|
756
|
-
$invalidate?.then(()
|
|
777
|
+
$invalidate?.then(function freezeInvalidateSub() {
|
|
757
778
|
freezedValue = null;
|
|
758
779
|
});
|
|
759
780
|
});
|
|
@@ -764,7 +785,7 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
|
|
|
764
785
|
const $eventName = Actual(eventName);
|
|
765
786
|
const $subscribeMethod = Actual(subscribeMethod);
|
|
766
787
|
const $unsubscribeMethod = Actual(unsubscribeMethod);
|
|
767
|
-
return Message((resolve, reject)
|
|
788
|
+
return Message(function FromEventImpl(resolve, reject) {
|
|
768
789
|
$emitter.catch(reject);
|
|
769
790
|
$eventName.catch(reject);
|
|
770
791
|
$subscribeMethod.catch(reject);
|
|
@@ -775,22 +796,24 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
|
|
|
775
796
|
lastR(v);
|
|
776
797
|
}
|
|
777
798
|
};
|
|
778
|
-
All($emitter, $eventName, $subscribeMethod).then(
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
799
|
+
All($emitter, $eventName, $subscribeMethod).then(function fromEventAllSub([
|
|
800
|
+
emitter2,
|
|
801
|
+
eventName2,
|
|
802
|
+
subscribe
|
|
803
|
+
]) {
|
|
804
|
+
lastR = resolve;
|
|
805
|
+
if (!emitter2?.[subscribe]) {
|
|
806
|
+
return;
|
|
785
807
|
}
|
|
786
|
-
|
|
787
|
-
|
|
808
|
+
emitter2[subscribe](eventName2, handler);
|
|
809
|
+
});
|
|
810
|
+
return function fromEventDestroy() {
|
|
788
811
|
lastR = null;
|
|
789
812
|
if (!$unsubscribeMethod) {
|
|
790
813
|
return;
|
|
791
814
|
}
|
|
792
815
|
All($emitter, $eventName, $unsubscribeMethod).then(
|
|
793
|
-
([emitter2, eventName2, unsubscribe])
|
|
816
|
+
function fromEventDestroyAllSub([emitter2, eventName2, unsubscribe]) {
|
|
794
817
|
emitter2?.[unsubscribe]?.(eventName2, handler);
|
|
795
818
|
}
|
|
796
819
|
);
|
|
@@ -799,10 +822,10 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
|
|
|
799
822
|
}
|
|
800
823
|
|
|
801
824
|
function Lazy(constructor) {
|
|
802
|
-
return Message((resolve, reject)
|
|
825
|
+
return Message(function LazyImpl(resolve, reject) {
|
|
803
826
|
const inst = constructor();
|
|
804
827
|
inst.catch(reject).then(resolve);
|
|
805
|
-
return ()
|
|
828
|
+
return function LazyDestroy() {
|
|
806
829
|
if (isDestroyable(inst)) {
|
|
807
830
|
inst.destroy();
|
|
808
831
|
}
|
|
@@ -812,14 +835,14 @@ function Lazy(constructor) {
|
|
|
812
835
|
|
|
813
836
|
function Map$1(base, target) {
|
|
814
837
|
const $base = Actual(base);
|
|
815
|
-
return Message((resolve, reject)
|
|
838
|
+
return Message(function MapImpl(resolve, reject) {
|
|
816
839
|
$base.catch(reject);
|
|
817
840
|
const infos = [];
|
|
818
841
|
const dc = DestroyContainer();
|
|
819
|
-
$base.then((v)
|
|
842
|
+
$base.then(function mapBaseSub(v) {
|
|
820
843
|
infos.length = 0;
|
|
821
844
|
dc.destroy();
|
|
822
|
-
v.forEach((val)
|
|
845
|
+
v.forEach(function mapValueForEach(val) {
|
|
823
846
|
let $val = val;
|
|
824
847
|
if (!isMessage($val)) {
|
|
825
848
|
$val = Of($val);
|
|
@@ -834,10 +857,10 @@ function Map$1(base, target) {
|
|
|
834
857
|
}
|
|
835
858
|
|
|
836
859
|
function Once($base) {
|
|
837
|
-
return Message((resolve, reject)
|
|
860
|
+
return Message(function OnceImpl(resolve, reject) {
|
|
838
861
|
let isFilled = false;
|
|
839
862
|
$base.catch(reject);
|
|
840
|
-
$base.then((v)
|
|
863
|
+
$base.then(function onceBaseSub(v) {
|
|
841
864
|
if (!isFilled) {
|
|
842
865
|
isFilled = true;
|
|
843
866
|
resolve(v);
|
|
@@ -847,16 +870,16 @@ function Once($base) {
|
|
|
847
870
|
}
|
|
848
871
|
|
|
849
872
|
function Piped($m, ...c) {
|
|
850
|
-
return c.reduce((msg, Constructor)
|
|
873
|
+
return c.reduce(function pipedReduce(msg, Constructor) {
|
|
851
874
|
return Actual(Constructor(msg));
|
|
852
875
|
}, Actual($m));
|
|
853
876
|
}
|
|
854
877
|
|
|
855
878
|
function Process($base, builder) {
|
|
856
|
-
return Message((resolve, reject)
|
|
879
|
+
return Message(function ProcessImpl(resolve, reject) {
|
|
857
880
|
const $res = Late();
|
|
858
881
|
const dc = DestroyContainer();
|
|
859
|
-
$base.then((v)
|
|
882
|
+
$base.then(function processBaseSub(v) {
|
|
860
883
|
dc.destroy();
|
|
861
884
|
const $msg = builder(v);
|
|
862
885
|
dc.add($msg);
|
|
@@ -865,24 +888,24 @@ function Process($base, builder) {
|
|
|
865
888
|
});
|
|
866
889
|
$base.catch(reject);
|
|
867
890
|
$res.then(resolve);
|
|
868
|
-
return ()
|
|
891
|
+
return function processDestructor() {
|
|
869
892
|
dc.destroy();
|
|
870
893
|
};
|
|
871
894
|
});
|
|
872
895
|
}
|
|
873
896
|
|
|
874
897
|
function Promisify($message) {
|
|
875
|
-
return new Promise((resolve, reject)
|
|
898
|
+
return new Promise(function promisifyExecutor(resolve, reject) {
|
|
876
899
|
$message.then(resolve, reject);
|
|
877
900
|
});
|
|
878
901
|
}
|
|
879
902
|
|
|
880
903
|
function Race(...messages) {
|
|
881
904
|
const $messages = messages.map(Actual);
|
|
882
|
-
return Message((resolve, reject)
|
|
905
|
+
return Message(function RaceImpl(resolve, reject) {
|
|
883
906
|
let responded = false;
|
|
884
|
-
$messages.forEach(($message)
|
|
885
|
-
$message.catch(reject).then((v)
|
|
907
|
+
$messages.forEach(function raceMessagesForEach($message) {
|
|
908
|
+
$message.catch(reject).then(function raceMessageSub(v) {
|
|
886
909
|
if (responded === false) {
|
|
887
910
|
responded = true;
|
|
888
911
|
resolve(v);
|
|
@@ -893,10 +916,10 @@ function Race(...messages) {
|
|
|
893
916
|
}
|
|
894
917
|
|
|
895
918
|
function Sequence($base) {
|
|
896
|
-
return Message((resolve, reject)
|
|
919
|
+
return Message(function SequenceImpl(resolve, reject) {
|
|
897
920
|
const result = [];
|
|
898
921
|
$base.catch(reject);
|
|
899
|
-
$base.then((v)
|
|
922
|
+
$base.then(function sequenceBaseSub(v) {
|
|
900
923
|
result.push(v);
|
|
901
924
|
resolve(result.slice());
|
|
902
925
|
});
|
|
@@ -905,10 +928,10 @@ function Sequence($base) {
|
|
|
905
928
|
|
|
906
929
|
function Stream(base) {
|
|
907
930
|
const $base = Actual(base);
|
|
908
|
-
return Message((resolve, reject)
|
|
931
|
+
return Message(function StreamImpl(resolve, reject) {
|
|
909
932
|
$base.catch(reject);
|
|
910
|
-
$base.then((v)
|
|
911
|
-
v.forEach((cv)
|
|
933
|
+
$base.then(function streamBaseSub(v) {
|
|
934
|
+
v.forEach(function streamBaseForEach(cv) {
|
|
912
935
|
resolve(cv);
|
|
913
936
|
});
|
|
914
937
|
});
|
|
@@ -918,7 +941,7 @@ function Stream(base) {
|
|
|
918
941
|
function Trackable(name, target) {
|
|
919
942
|
Context("trackable", { name, action: "created" }).then(Void());
|
|
920
943
|
if (isMessage(target)) {
|
|
921
|
-
target.then((value)
|
|
944
|
+
target.then(function trackableTargetSub(value) {
|
|
922
945
|
Context("trackable", { name, action: "value", value }).then(Void());
|
|
923
946
|
});
|
|
924
947
|
}
|
|
@@ -948,9 +971,14 @@ function Value(target) {
|
|
|
948
971
|
}
|
|
949
972
|
|
|
950
973
|
const silentiumPrint = (...messages) => {
|
|
951
|
-
Applied(
|
|
952
|
-
|
|
953
|
-
|
|
974
|
+
Applied(
|
|
975
|
+
All(
|
|
976
|
+
...messages.map(function silentiumPrintAllMap(e) {
|
|
977
|
+
return Shared(e);
|
|
978
|
+
})
|
|
979
|
+
),
|
|
980
|
+
JSON.stringify
|
|
981
|
+
).then(console.log);
|
|
954
982
|
};
|
|
955
983
|
const silentiumValue = ($message) => Primitive($message).primitive();
|
|
956
984
|
class MessageDestroyable {
|