silentium 0.0.158 → 0.0.161
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 +21 -0
- package/dist/silentium.cjs +215 -213
- package/dist/silentium.cjs.map +1 -1
- package/dist/silentium.d.ts +4 -6
- package/dist/silentium.js +215 -213
- 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 +215 -213
- package/dist/silentium.mjs.map +1 -1
- package/package.json +1 -1
- package/src/base/Message.ts +4 -25
- package/src/base/New.ts +1 -1
- package/src/components/All.ts +4 -3
- package/src/components/Any.ts +3 -2
- package/src/components/Applied.ts +3 -2
- package/src/components/Chain.ts +28 -25
- package/src/components/ContextOf.ts +3 -2
- package/src/components/ExecutorApplied.ts +3 -2
- package/src/components/Filtered.ts +4 -3
- package/src/components/Freeze.test.ts +124 -0
- package/src/components/Freeze.ts +22 -0
- package/src/components/FromEvent.ts +6 -2
- package/src/components/Map.ts +3 -2
- package/src/components/Once.ts +3 -2
- package/src/components/Sequence.ts +3 -2
- package/src/components/Stream.ts +3 -2
package/dist/silentium.mjs
CHANGED
|
@@ -80,146 +80,6 @@ class Rejections {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
var __defProp$5 = Object.defineProperty;
|
|
84
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
85
|
-
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
86
|
-
function Late(v) {
|
|
87
|
-
return new LateImpl(v);
|
|
88
|
-
}
|
|
89
|
-
class LateImpl {
|
|
90
|
-
constructor(v) {
|
|
91
|
-
this.v = v;
|
|
92
|
-
__publicField$5(this, "rejections", new Rejections());
|
|
93
|
-
__publicField$5(this, "lateR", null);
|
|
94
|
-
__publicField$5(this, "notify", () => {
|
|
95
|
-
if (isFilled(this.v) && this.lateR) {
|
|
96
|
-
try {
|
|
97
|
-
this.lateR(this.v);
|
|
98
|
-
} catch (e) {
|
|
99
|
-
this.rejections.reject(e);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
then(r) {
|
|
105
|
-
if (this.lateR) {
|
|
106
|
-
throw new Error(
|
|
107
|
-
"Late component gets new resolver, when another was already connected!"
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
this.lateR = r;
|
|
111
|
-
this.notify();
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
use(value) {
|
|
115
|
-
this.v = value;
|
|
116
|
-
this.notify();
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
catch(rejected) {
|
|
120
|
-
this.rejections.catch(rejected);
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
var __defProp$4 = Object.defineProperty;
|
|
126
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
127
|
-
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
128
|
-
function Primitive($base, theValue = null) {
|
|
129
|
-
return new PrimitiveImpl($base, theValue);
|
|
130
|
-
}
|
|
131
|
-
class PrimitiveImpl {
|
|
132
|
-
constructor($base, theValue = null) {
|
|
133
|
-
this.$base = $base;
|
|
134
|
-
this.theValue = theValue;
|
|
135
|
-
__publicField$4(this, "touched", false);
|
|
136
|
-
}
|
|
137
|
-
ensureTouched() {
|
|
138
|
-
if (!this.touched) {
|
|
139
|
-
this.$base.then((v) => {
|
|
140
|
-
this.theValue = v;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
this.touched = true;
|
|
144
|
-
}
|
|
145
|
-
[Symbol.toPrimitive]() {
|
|
146
|
-
this.ensureTouched();
|
|
147
|
-
return this.theValue;
|
|
148
|
-
}
|
|
149
|
-
primitive() {
|
|
150
|
-
this.ensureTouched();
|
|
151
|
-
return this.theValue;
|
|
152
|
-
}
|
|
153
|
-
primitiveWithException() {
|
|
154
|
-
this.ensureTouched();
|
|
155
|
-
if (this.theValue === null) {
|
|
156
|
-
throw new Error("Primitive value is null");
|
|
157
|
-
}
|
|
158
|
-
return this.theValue;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
var __defProp$3 = Object.defineProperty;
|
|
163
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
164
|
-
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
165
|
-
function Shared($base) {
|
|
166
|
-
return new SharedImpl($base);
|
|
167
|
-
}
|
|
168
|
-
class SharedImpl {
|
|
169
|
-
constructor($base) {
|
|
170
|
-
this.$base = $base;
|
|
171
|
-
__publicField$3(this, "resolver", (v) => {
|
|
172
|
-
this.lastV = v;
|
|
173
|
-
this.resolvers.forEach((r) => {
|
|
174
|
-
r(v);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
__publicField$3(this, "lastV");
|
|
178
|
-
__publicField$3(this, "resolvers", /* @__PURE__ */ new Set());
|
|
179
|
-
__publicField$3(this, "source");
|
|
180
|
-
if (isSource($base)) {
|
|
181
|
-
this.source = $base;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
then(resolved) {
|
|
185
|
-
this.resolvers.add(resolved);
|
|
186
|
-
if (this.resolvers.size === 1) {
|
|
187
|
-
this.$base.then(this.resolver);
|
|
188
|
-
} else if (isFilled(this.lastV)) {
|
|
189
|
-
resolved(this.lastV);
|
|
190
|
-
}
|
|
191
|
-
return this;
|
|
192
|
-
}
|
|
193
|
-
use(value) {
|
|
194
|
-
if (this.source) {
|
|
195
|
-
this.source.use(value);
|
|
196
|
-
} else {
|
|
197
|
-
this.resolver(value);
|
|
198
|
-
}
|
|
199
|
-
return this;
|
|
200
|
-
}
|
|
201
|
-
catch(rejected) {
|
|
202
|
-
this.$base.catch(rejected);
|
|
203
|
-
return this;
|
|
204
|
-
}
|
|
205
|
-
destroy() {
|
|
206
|
-
this.resolvers.clear();
|
|
207
|
-
return this;
|
|
208
|
-
}
|
|
209
|
-
value() {
|
|
210
|
-
return Primitive(this);
|
|
211
|
-
}
|
|
212
|
-
chain(m) {
|
|
213
|
-
m.then(this.use.bind(this));
|
|
214
|
-
return this;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function LateShared(value) {
|
|
219
|
-
const l = Late(value);
|
|
220
|
-
return Shared(l);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
83
|
function ensureFunction(v, label) {
|
|
224
84
|
if (typeof v !== "function") {
|
|
225
85
|
throw new Error(`${label}: is not function`);
|
|
@@ -231,37 +91,22 @@ function ensureMessage(v, label) {
|
|
|
231
91
|
}
|
|
232
92
|
}
|
|
233
93
|
|
|
234
|
-
var __defProp$
|
|
235
|
-
var __defNormalProp$
|
|
236
|
-
var __publicField$
|
|
237
|
-
function Message(executor
|
|
238
|
-
return new MessageRx(executor
|
|
94
|
+
var __defProp$5 = Object.defineProperty;
|
|
95
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
96
|
+
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
97
|
+
function Message(executor) {
|
|
98
|
+
return new MessageRx(executor);
|
|
239
99
|
}
|
|
240
100
|
class MessageRx {
|
|
241
|
-
constructor(executor
|
|
101
|
+
constructor(executor) {
|
|
242
102
|
this.executor = executor;
|
|
243
|
-
this
|
|
244
|
-
__publicField$
|
|
245
|
-
__publicField$2(this, "dc", DestroyContainer());
|
|
246
|
-
__publicField$2(this, "executed", false);
|
|
247
|
-
__publicField$2(this, "late", LateShared());
|
|
103
|
+
__publicField$5(this, "rejections", new Rejections());
|
|
104
|
+
__publicField$5(this, "dc", DestroyContainer());
|
|
248
105
|
ensureFunction(executor, "Message: executor");
|
|
249
106
|
}
|
|
250
107
|
then(resolve) {
|
|
251
108
|
try {
|
|
252
|
-
|
|
253
|
-
this.dc.add(this.executor(resolve, this.rejections.reject));
|
|
254
|
-
} else if (!this.executed) {
|
|
255
|
-
this.executed = true;
|
|
256
|
-
this.late.then(resolve);
|
|
257
|
-
this.dc.add(
|
|
258
|
-
this.executor((v) => {
|
|
259
|
-
this.late.use(v);
|
|
260
|
-
}, this.rejections.reject)
|
|
261
|
-
);
|
|
262
|
-
} else {
|
|
263
|
-
this.late.then(resolve);
|
|
264
|
-
}
|
|
109
|
+
this.dc.add(this.executor(resolve, this.rejections.reject));
|
|
265
110
|
} catch (e) {
|
|
266
111
|
this.rejections.reject(e);
|
|
267
112
|
}
|
|
@@ -316,16 +161,16 @@ function Local(_base) {
|
|
|
316
161
|
});
|
|
317
162
|
}
|
|
318
163
|
|
|
319
|
-
var __defProp$
|
|
320
|
-
var __defNormalProp$
|
|
321
|
-
var __publicField$
|
|
164
|
+
var __defProp$4 = Object.defineProperty;
|
|
165
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
166
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
322
167
|
function MessageSource(messageExecutor, sourceExecutor) {
|
|
323
168
|
return new MessageSourceImpl(messageExecutor, sourceExecutor);
|
|
324
169
|
}
|
|
325
170
|
class MessageSourceImpl {
|
|
326
171
|
constructor(messageExecutor, sourceExecutor) {
|
|
327
172
|
this.sourceExecutor = sourceExecutor;
|
|
328
|
-
__publicField$
|
|
173
|
+
__publicField$4(this, "message");
|
|
329
174
|
this.message = Message(messageExecutor);
|
|
330
175
|
}
|
|
331
176
|
use(value) {
|
|
@@ -345,7 +190,7 @@ class MessageSourceImpl {
|
|
|
345
190
|
function New(construct) {
|
|
346
191
|
return Message(function NewImpl(resolve) {
|
|
347
192
|
resolve(construct());
|
|
348
|
-
}
|
|
193
|
+
});
|
|
349
194
|
}
|
|
350
195
|
|
|
351
196
|
function Void() {
|
|
@@ -358,20 +203,21 @@ const isAllFilled = (keysFilled, keysKnown) => {
|
|
|
358
203
|
};
|
|
359
204
|
function All(...messages) {
|
|
360
205
|
const $messages = messages.map(ActualMessage);
|
|
361
|
-
return Message(function AllImpl(
|
|
206
|
+
return Message(function AllImpl(resolve, reject) {
|
|
362
207
|
const known = new Set(Object.keys(messages));
|
|
363
208
|
const filled = /* @__PURE__ */ new Set();
|
|
364
209
|
const result = [];
|
|
365
210
|
if (known.size === 0) {
|
|
366
|
-
|
|
211
|
+
resolve([]);
|
|
367
212
|
return;
|
|
368
213
|
}
|
|
369
214
|
$messages.map((m, key) => {
|
|
215
|
+
m.catch(reject);
|
|
370
216
|
m.then((v) => {
|
|
371
217
|
filled.add(key.toString());
|
|
372
218
|
result[key] = v;
|
|
373
219
|
if (isAllFilled(filled, known)) {
|
|
374
|
-
|
|
220
|
+
resolve(result);
|
|
375
221
|
}
|
|
376
222
|
});
|
|
377
223
|
});
|
|
@@ -380,18 +226,20 @@ function All(...messages) {
|
|
|
380
226
|
|
|
381
227
|
function Any(...messages) {
|
|
382
228
|
const $messages = messages.map(ActualMessage);
|
|
383
|
-
return Message(function AnyImpl(
|
|
229
|
+
return Message(function AnyImpl(resolve, reject) {
|
|
384
230
|
$messages.forEach((message) => {
|
|
385
|
-
message.
|
|
231
|
+
message.catch(reject);
|
|
232
|
+
message.then(resolve);
|
|
386
233
|
});
|
|
387
234
|
});
|
|
388
235
|
}
|
|
389
236
|
|
|
390
237
|
function Applied(base, applier) {
|
|
391
238
|
const $base = ActualMessage(base);
|
|
392
|
-
return Message(function AppliedImpl(
|
|
239
|
+
return Message(function AppliedImpl(resolve, reject) {
|
|
240
|
+
$base.catch(reject);
|
|
393
241
|
$base.then((v) => {
|
|
394
|
-
|
|
242
|
+
resolve(applier(v));
|
|
395
243
|
});
|
|
396
244
|
});
|
|
397
245
|
}
|
|
@@ -402,6 +250,48 @@ function AppliedDestructured($base, applier) {
|
|
|
402
250
|
});
|
|
403
251
|
}
|
|
404
252
|
|
|
253
|
+
var __defProp$3 = Object.defineProperty;
|
|
254
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
255
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
256
|
+
function Late(v) {
|
|
257
|
+
return new LateImpl(v);
|
|
258
|
+
}
|
|
259
|
+
class LateImpl {
|
|
260
|
+
constructor(v) {
|
|
261
|
+
this.v = v;
|
|
262
|
+
__publicField$3(this, "rejections", new Rejections());
|
|
263
|
+
__publicField$3(this, "lateR", null);
|
|
264
|
+
__publicField$3(this, "notify", () => {
|
|
265
|
+
if (isFilled(this.v) && this.lateR) {
|
|
266
|
+
try {
|
|
267
|
+
this.lateR(this.v);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
this.rejections.reject(e);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
then(r) {
|
|
275
|
+
if (this.lateR) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
"Late component gets new resolver, when another was already connected!"
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
this.lateR = r;
|
|
281
|
+
this.notify();
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
use(value) {
|
|
285
|
+
this.v = value;
|
|
286
|
+
this.notify();
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
catch(rejected) {
|
|
290
|
+
this.rejections.catch(rejected);
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
405
295
|
function Catch($base) {
|
|
406
296
|
const rejections = new Rejections();
|
|
407
297
|
$base.catch(rejections.reject);
|
|
@@ -414,28 +304,31 @@ function Catch($base) {
|
|
|
414
304
|
|
|
415
305
|
function Chain(...messages) {
|
|
416
306
|
const $messages = messages.map(ActualMessage);
|
|
417
|
-
return Message(
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
307
|
+
return Message(
|
|
308
|
+
function ChainImpl(resolve, reject) {
|
|
309
|
+
let $latest;
|
|
310
|
+
const handleMessage = (index) => {
|
|
311
|
+
const message = $messages[index];
|
|
312
|
+
message.catch(reject);
|
|
313
|
+
const next = $messages[index + 1];
|
|
314
|
+
message.then((v) => {
|
|
315
|
+
oneMessage(v, next, index);
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
function oneMessage(v, next, index) {
|
|
319
|
+
if (!next) {
|
|
320
|
+
$latest = v;
|
|
321
|
+
}
|
|
322
|
+
if ($latest) {
|
|
323
|
+
resolve($latest);
|
|
324
|
+
}
|
|
325
|
+
if (next && !$latest) {
|
|
326
|
+
handleMessage(index + 1);
|
|
327
|
+
}
|
|
435
328
|
}
|
|
329
|
+
handleMessage(0);
|
|
436
330
|
}
|
|
437
|
-
|
|
438
|
-
});
|
|
331
|
+
);
|
|
439
332
|
}
|
|
440
333
|
|
|
441
334
|
Context.transport = /* @__PURE__ */ new Map();
|
|
@@ -472,22 +365,122 @@ function ContextChain(base) {
|
|
|
472
365
|
};
|
|
473
366
|
}
|
|
474
367
|
|
|
368
|
+
var __defProp$2 = Object.defineProperty;
|
|
369
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
370
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "" , value);
|
|
371
|
+
function Primitive($base, theValue = null) {
|
|
372
|
+
return new PrimitiveImpl($base, theValue);
|
|
373
|
+
}
|
|
374
|
+
class PrimitiveImpl {
|
|
375
|
+
constructor($base, theValue = null) {
|
|
376
|
+
this.$base = $base;
|
|
377
|
+
this.theValue = theValue;
|
|
378
|
+
__publicField$2(this, "touched", false);
|
|
379
|
+
}
|
|
380
|
+
ensureTouched() {
|
|
381
|
+
if (!this.touched) {
|
|
382
|
+
this.$base.then((v) => {
|
|
383
|
+
this.theValue = v;
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
this.touched = true;
|
|
387
|
+
}
|
|
388
|
+
[Symbol.toPrimitive]() {
|
|
389
|
+
this.ensureTouched();
|
|
390
|
+
return this.theValue;
|
|
391
|
+
}
|
|
392
|
+
primitive() {
|
|
393
|
+
this.ensureTouched();
|
|
394
|
+
return this.theValue;
|
|
395
|
+
}
|
|
396
|
+
primitiveWithException() {
|
|
397
|
+
this.ensureTouched();
|
|
398
|
+
if (this.theValue === null) {
|
|
399
|
+
throw new Error("Primitive value is null");
|
|
400
|
+
}
|
|
401
|
+
return this.theValue;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
var __defProp$1 = Object.defineProperty;
|
|
406
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
407
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
408
|
+
function Shared($base) {
|
|
409
|
+
return new SharedImpl($base);
|
|
410
|
+
}
|
|
411
|
+
class SharedImpl {
|
|
412
|
+
constructor($base) {
|
|
413
|
+
this.$base = $base;
|
|
414
|
+
__publicField$1(this, "resolver", (v) => {
|
|
415
|
+
this.lastV = v;
|
|
416
|
+
this.resolvers.forEach((r) => {
|
|
417
|
+
r(v);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
__publicField$1(this, "lastV");
|
|
421
|
+
__publicField$1(this, "resolvers", /* @__PURE__ */ new Set());
|
|
422
|
+
__publicField$1(this, "source");
|
|
423
|
+
if (isSource($base)) {
|
|
424
|
+
this.source = $base;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
then(resolved) {
|
|
428
|
+
this.resolvers.add(resolved);
|
|
429
|
+
if (this.resolvers.size === 1) {
|
|
430
|
+
this.$base.then(this.resolver);
|
|
431
|
+
} else if (isFilled(this.lastV)) {
|
|
432
|
+
resolved(this.lastV);
|
|
433
|
+
}
|
|
434
|
+
return this;
|
|
435
|
+
}
|
|
436
|
+
use(value) {
|
|
437
|
+
if (this.source) {
|
|
438
|
+
this.source.use(value);
|
|
439
|
+
} else {
|
|
440
|
+
this.resolver(value);
|
|
441
|
+
}
|
|
442
|
+
return this;
|
|
443
|
+
}
|
|
444
|
+
catch(rejected) {
|
|
445
|
+
this.$base.catch(rejected);
|
|
446
|
+
return this;
|
|
447
|
+
}
|
|
448
|
+
destroy() {
|
|
449
|
+
this.resolvers.clear();
|
|
450
|
+
return this;
|
|
451
|
+
}
|
|
452
|
+
value() {
|
|
453
|
+
return Primitive(this);
|
|
454
|
+
}
|
|
455
|
+
chain(m) {
|
|
456
|
+
m.then(this.use.bind(this));
|
|
457
|
+
return this;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function LateShared(value) {
|
|
462
|
+
const l = Late(value);
|
|
463
|
+
return Shared(l);
|
|
464
|
+
}
|
|
465
|
+
|
|
475
466
|
function ContextOf(transport) {
|
|
476
467
|
const $msg = LateShared();
|
|
477
468
|
Context.transport.set(transport, $msg.use.bind($msg));
|
|
478
|
-
return Message((
|
|
479
|
-
$msg.
|
|
469
|
+
return Message((resolve, reject) => {
|
|
470
|
+
$msg.catch(reject);
|
|
471
|
+
$msg.then(resolve);
|
|
480
472
|
});
|
|
481
473
|
}
|
|
482
474
|
|
|
483
475
|
function Filtered(base, predicate, defaultValue) {
|
|
484
476
|
const $base = ActualMessage(base);
|
|
485
|
-
return Message(function FilteredImpl(
|
|
477
|
+
return Message(function FilteredImpl(resolve, reject) {
|
|
478
|
+
$base.catch(reject);
|
|
486
479
|
$base.then((v) => {
|
|
487
480
|
if (predicate(v)) {
|
|
488
|
-
|
|
481
|
+
resolve(v);
|
|
489
482
|
} else if (defaultValue !== void 0) {
|
|
490
|
-
|
|
483
|
+
resolve(defaultValue);
|
|
491
484
|
}
|
|
492
485
|
});
|
|
493
486
|
});
|
|
@@ -519,8 +512,9 @@ class EmptyImpl {
|
|
|
519
512
|
}
|
|
520
513
|
|
|
521
514
|
function ExecutorApplied($base, applier) {
|
|
522
|
-
return Message(function ExecutorAppliedImpl(
|
|
523
|
-
$base.
|
|
515
|
+
return Message(function ExecutorAppliedImpl(resolve, reject) {
|
|
516
|
+
$base.catch(reject);
|
|
517
|
+
$base.then(applier(resolve));
|
|
524
518
|
});
|
|
525
519
|
}
|
|
526
520
|
|
|
@@ -529,7 +523,11 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
|
|
|
529
523
|
const $eventName = ActualMessage(eventName);
|
|
530
524
|
const $subscribeMethod = ActualMessage(subscribeMethod);
|
|
531
525
|
const $unsubscribeMethod = ActualMessage(unsubscribeMethod);
|
|
532
|
-
return Message((
|
|
526
|
+
return Message((resolve, reject) => {
|
|
527
|
+
$emitter.catch(reject);
|
|
528
|
+
$eventName.catch(reject);
|
|
529
|
+
$subscribeMethod.catch(reject);
|
|
530
|
+
$unsubscribeMethod.catch(reject);
|
|
533
531
|
let lastR = null;
|
|
534
532
|
const handler = (v) => {
|
|
535
533
|
if (lastR) {
|
|
@@ -538,7 +536,7 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
|
|
|
538
536
|
};
|
|
539
537
|
All($emitter, $eventName, $subscribeMethod).then(
|
|
540
538
|
([emitter2, eventName2, subscribe]) => {
|
|
541
|
-
lastR =
|
|
539
|
+
lastR = resolve;
|
|
542
540
|
if (!emitter2?.[subscribe]) {
|
|
543
541
|
return;
|
|
544
542
|
}
|
|
@@ -561,7 +559,8 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
|
|
|
561
559
|
|
|
562
560
|
function Map$1(base, target) {
|
|
563
561
|
const $base = ActualMessage(base);
|
|
564
|
-
return Message((
|
|
562
|
+
return Message((resolve, reject) => {
|
|
563
|
+
$base.catch(reject);
|
|
565
564
|
const infos = [];
|
|
566
565
|
const dc = DestroyContainer();
|
|
567
566
|
$base.then((v) => {
|
|
@@ -575,18 +574,19 @@ function Map$1(base, target) {
|
|
|
575
574
|
dc.add(info);
|
|
576
575
|
infos.push(info);
|
|
577
576
|
});
|
|
578
|
-
All(...infos).then(
|
|
577
|
+
All(...infos).then(resolve);
|
|
579
578
|
});
|
|
580
579
|
});
|
|
581
580
|
}
|
|
582
581
|
|
|
583
582
|
function Once($base) {
|
|
584
|
-
return Message((
|
|
583
|
+
return Message((resolve, reject) => {
|
|
585
584
|
let isFilled = false;
|
|
585
|
+
$base.catch(reject);
|
|
586
586
|
$base.then((v) => {
|
|
587
587
|
if (!isFilled) {
|
|
588
588
|
isFilled = true;
|
|
589
|
-
|
|
589
|
+
resolve(v);
|
|
590
590
|
}
|
|
591
591
|
});
|
|
592
592
|
});
|
|
@@ -612,21 +612,23 @@ function Process($base, builder) {
|
|
|
612
612
|
}
|
|
613
613
|
|
|
614
614
|
function Sequence($base) {
|
|
615
|
-
return Message((
|
|
615
|
+
return Message((resolve, reject) => {
|
|
616
616
|
const result = [];
|
|
617
|
+
$base.catch(reject);
|
|
617
618
|
$base.then((v) => {
|
|
618
619
|
result.push(v);
|
|
619
|
-
|
|
620
|
+
resolve(result);
|
|
620
621
|
});
|
|
621
622
|
});
|
|
622
623
|
}
|
|
623
624
|
|
|
624
625
|
function Stream(base) {
|
|
625
626
|
const $base = ActualMessage(base);
|
|
626
|
-
return Message((
|
|
627
|
+
return Message((resolve, reject) => {
|
|
628
|
+
$base.catch(reject);
|
|
627
629
|
$base.then((v) => {
|
|
628
630
|
v.forEach((cv) => {
|
|
629
|
-
|
|
631
|
+
resolve(cv);
|
|
630
632
|
});
|
|
631
633
|
});
|
|
632
634
|
});
|