silentium-components 0.0.82 → 0.0.83

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/silentium-components.cjs +130 -130
  3. package/dist/silentium-components.cjs.map +1 -1
  4. package/dist/silentium-components.d.ts +9 -9
  5. package/dist/silentium-components.js +131 -131
  6. package/dist/silentium-components.js.map +1 -1
  7. package/dist/silentium-components.min.js +1 -1
  8. package/dist/silentium-components.min.mjs +1 -1
  9. package/dist/silentium-components.min.mjs.map +1 -1
  10. package/dist/silentium-components.mjs +131 -131
  11. package/dist/silentium-components.mjs.map +1 -1
  12. package/package.json +2 -2
  13. package/src/behaviors/Branch._main.test.ts +2 -2
  14. package/src/behaviors/Branch._values.test.ts +2 -2
  15. package/src/behaviors/Branch.branchesDontAffectResult.test.ts +2 -2
  16. package/src/behaviors/Branch.dontRespondAfterRespond.test.ts +5 -5
  17. package/src/behaviors/Branch.ts +5 -5
  18. package/src/behaviors/BranchLazy._main.test.ts +4 -4
  19. package/src/behaviors/BranchLazy.ts +8 -8
  20. package/src/behaviors/Const.test.ts +3 -3
  21. package/src/behaviors/Const.ts +5 -5
  22. package/src/behaviors/Deadline._main.test.ts +2 -2
  23. package/src/behaviors/Deadline._value.test.ts +3 -3
  24. package/src/behaviors/Deadline.ts +9 -9
  25. package/src/behaviors/Deferred.test.ts +3 -3
  26. package/src/behaviors/Deferred.ts +5 -11
  27. package/src/behaviors/Detached.test.ts +3 -3
  28. package/src/behaviors/Detached.ts +2 -2
  29. package/src/behaviors/Dirty.test.ts +2 -2
  30. package/src/behaviors/Dirty.ts +5 -5
  31. package/src/behaviors/Loading.test.ts +2 -2
  32. package/src/behaviors/Loading.ts +6 -6
  33. package/src/behaviors/Lock.test.ts +2 -2
  34. package/src/behaviors/Lock.ts +5 -5
  35. package/src/behaviors/Memo.test.ts +4 -4
  36. package/src/behaviors/Memo.ts +5 -5
  37. package/src/behaviors/OnlyChanged.test.ts +3 -3
  38. package/src/behaviors/OnlyChanged.ts +5 -5
  39. package/src/behaviors/Part.test.ts +3 -3
  40. package/src/behaviors/Part.ts +5 -5
  41. package/src/behaviors/Path._keyRaw.test.ts +2 -2
  42. package/src/behaviors/Path._main.test.ts +2 -2
  43. package/src/behaviors/Path.index.test.ts +2 -2
  44. package/src/behaviors/Path.nested.test.ts +2 -2
  45. package/src/behaviors/Path.ts +5 -5
  46. package/src/behaviors/Polling.ts +5 -5
  47. package/src/behaviors/Shot._main.test.ts +3 -3
  48. package/src/behaviors/Shot._onlyChanged.test.ts +3 -3
  49. package/src/behaviors/Shot.ts +5 -11
  50. package/src/behaviors/Task.test.ts +5 -5
  51. package/src/behaviors/Task.ts +2 -2
  52. package/src/behaviors/Tick.test.ts +2 -2
  53. package/src/behaviors/Tick.ts +5 -5
  54. package/src/behaviors/Transaction.ts +6 -6
  55. package/src/boolean/And.test.ts +2 -2
  56. package/src/boolean/And.ts +5 -5
  57. package/src/boolean/Bool.test.ts +2 -2
  58. package/src/boolean/Bool.ts +2 -2
  59. package/src/boolean/Not.test.ts +2 -2
  60. package/src/boolean/Not.ts +5 -5
  61. package/src/boolean/Or.test.ts +2 -2
  62. package/src/boolean/Or.ts +5 -5
  63. package/src/formats/FromJson.ts +6 -6
  64. package/src/formats/ToJson.ts +6 -6
  65. package/src/lists/First.test.ts +2 -2
  66. package/src/lists/First.ts +2 -2
  67. package/src/navigation/Router._destroy.test.ts +7 -7
  68. package/src/navigation/Router._firstMatch.test.ts +7 -7
  69. package/src/navigation/Router._main.test.ts +7 -7
  70. package/src/navigation/Router._nested.test.ts +16 -16
  71. package/src/navigation/Router.ts +11 -11
  72. package/src/strings/Concatenated.test.ts +2 -2
  73. package/src/strings/Concatenated.ts +5 -5
  74. package/src/strings/Template._main.test.ts +3 -3
  75. package/src/strings/Template._place.test.ts +2 -2
  76. package/src/strings/Template.ts +3 -3
  77. package/src/structures/HashTable.test.ts +2 -2
  78. package/src/structures/HashTable.ts +5 -5
  79. package/src/structures/Record._main.test.ts +2 -2
  80. package/src/structures/Record._mixed.test.ts +2 -2
  81. package/src/structures/Record.concatenated.test.ts +4 -4
  82. package/src/structures/Record.nested.test.ts +2 -2
  83. package/src/structures/Record.ts +5 -5
  84. package/src/system/RegexpMatch._group.test.ts +2 -2
  85. package/src/system/RegexpMatch._main.test.ts +2 -2
  86. package/src/system/RegexpMatch.ts +5 -5
  87. package/src/system/RegexpMatched.test.ts +2 -2
  88. package/src/system/RegexpMatched.ts +5 -5
  89. package/src/system/RegexpReplaced.test.ts +2 -2
  90. package/src/system/RegexpReplaced.ts +5 -5
  91. package/src/system/Set.test.ts +2 -2
  92. package/src/system/Set.ts +5 -5
@@ -1,17 +1,17 @@
1
- import { ActualMessage, Message, Primitive, Transport, DestroyContainer, Shared, Filtered, isFilled, Late, Applied, All, SharedSource, ExecutorApplied, LateShared, Of, isMessage, isDestroyable } from 'silentium';
1
+ import { ActualMessage, Message, Primitive, Tap, DestroyContainer, Shared, Filtered, isFilled, Late, Applied, All, SharedSource, ExecutorApplied, LateShared, Of, isMessage, isDestroyable } from 'silentium';
2
2
 
3
3
  function Branch(_condition, _left, _right) {
4
4
  const $condition = ActualMessage(_condition);
5
5
  const $left = ActualMessage(_left);
6
6
  const $right = _right && ActualMessage(_right);
7
- return Message((transport) => {
7
+ return Message(function() {
8
8
  const left = Primitive($left);
9
9
  let right;
10
10
  if ($right !== void 0) {
11
11
  right = Primitive($right);
12
12
  }
13
- $condition.to(
14
- Transport((v) => {
13
+ $condition.pipe(
14
+ Tap((v) => {
15
15
  let result = null;
16
16
  if (v) {
17
17
  result = left.primitive();
@@ -19,7 +19,7 @@ function Branch(_condition, _left, _right) {
19
19
  result = right.primitive();
20
20
  }
21
21
  if (result !== null) {
22
- transport.use(result);
22
+ this.use(result);
23
23
  }
24
24
  })
25
25
  );
@@ -27,13 +27,13 @@ function Branch(_condition, _left, _right) {
27
27
  }
28
28
 
29
29
  function BranchLazy($condition, $left, $right) {
30
- return Message((transport) => {
30
+ return Message(function() {
31
31
  const dc = DestroyContainer();
32
32
  const destructor = () => {
33
33
  dc.destroy();
34
34
  };
35
- $condition.to(
36
- Transport((v) => {
35
+ $condition.pipe(
36
+ Tap((v) => {
37
37
  destructor();
38
38
  let instance;
39
39
  if (v) {
@@ -42,7 +42,7 @@ function BranchLazy($condition, $left, $right) {
42
42
  instance = $right.use();
43
43
  }
44
44
  if (instance !== void 0) {
45
- instance.to(transport);
45
+ instance.pipe(this);
46
46
  dc.add(instance);
47
47
  }
48
48
  })
@@ -52,10 +52,10 @@ function BranchLazy($condition, $left, $right) {
52
52
  }
53
53
 
54
54
  function Constant(permanent, $trigger) {
55
- return Message((transport) => {
56
- $trigger.to(
57
- Transport(() => {
58
- transport.use(permanent);
55
+ return Message(function() {
56
+ $trigger.pipe(
57
+ Tap(() => {
58
+ this.use(permanent);
59
59
  })
60
60
  );
61
61
  });
@@ -63,11 +63,11 @@ function Constant(permanent, $trigger) {
63
63
 
64
64
  function Deadline(error, $base, _timeout) {
65
65
  const $timeout = ActualMessage(_timeout);
66
- return Message((transport) => {
66
+ return Message(function() {
67
67
  let timer = 0;
68
68
  const base = Shared($base, true);
69
- $timeout.to(
70
- Transport((timeout) => {
69
+ $timeout.pipe(
70
+ Tap((timeout) => {
71
71
  if (timer) {
72
72
  clearTimeout(timer);
73
73
  }
@@ -80,9 +80,9 @@ function Deadline(error, $base, _timeout) {
80
80
  error.use(new Error("Timeout reached in Deadline"));
81
81
  }, timeout);
82
82
  const f = Filtered(base, () => !timeoutReached);
83
- f.to(transport);
84
- base.to(
85
- Transport(() => {
83
+ f.pipe(this);
84
+ base.pipe(
85
+ Tap(() => {
86
86
  timeoutReached = true;
87
87
  })
88
88
  );
@@ -92,13 +92,13 @@ function Deadline(error, $base, _timeout) {
92
92
  }
93
93
 
94
94
  function Deferred($base, $trigger) {
95
- return Message((transport) => {
95
+ return Message(function() {
96
96
  const base = Primitive($base);
97
- $trigger.to(
98
- Transport(() => {
97
+ $trigger.pipe(
98
+ Tap(() => {
99
99
  const value = base.primitive();
100
100
  if (isFilled(value)) {
101
- transport.use(value);
101
+ this.use(value);
102
102
  }
103
103
  })
104
104
  );
@@ -106,10 +106,10 @@ function Deferred($base, $trigger) {
106
106
  }
107
107
 
108
108
  function Detached($base) {
109
- return Message((transport) => {
109
+ return Message(function() {
110
110
  const v = Primitive($base).primitive();
111
111
  if (isFilled(v)) {
112
- transport.use(v);
112
+ this.use(v);
113
113
  }
114
114
  });
115
115
  }
@@ -133,10 +133,10 @@ class DirtySource {
133
133
  this.cloner = cloner;
134
134
  }
135
135
  }
136
- to(transport) {
136
+ pipe(transport) {
137
137
  const $comparing = Applied(this.$comparing, this.cloner);
138
- All($comparing, this.$base).to(
139
- Transport(([comparing, base]) => {
138
+ All($comparing, this.$base).pipe(
139
+ Tap(([comparing, base]) => {
140
140
  if (!comparing) {
141
141
  return;
142
142
  }
@@ -163,33 +163,33 @@ class DirtySource {
163
163
  }
164
164
  }
165
165
 
166
- function Loading($loadingStart, $loadingFinish) {
167
- return Message((transport) => {
168
- $loadingStart.to(Transport(() => transport.use(true)));
169
- $loadingFinish.to(Transport(() => transport.use(false)));
166
+ function Loading($start, $finish) {
167
+ return Message(function() {
168
+ $start.pipe(Tap(() => this.use(true)));
169
+ $finish.pipe(Tap(() => this.use(false)));
170
170
  });
171
171
  }
172
172
 
173
173
  function Lock($base, $lock) {
174
- return Message((transport) => {
174
+ return Message(function() {
175
175
  let locked = false;
176
- $lock.to(
177
- Transport((newLock) => {
176
+ $lock.pipe(
177
+ Tap((newLock) => {
178
178
  locked = newLock;
179
179
  })
180
180
  );
181
181
  const i = Filtered($base, () => !locked);
182
- i.to(transport);
182
+ i.pipe(this);
183
183
  });
184
184
  }
185
185
 
186
186
  function Memo($base) {
187
- return Message((transport) => {
187
+ return Message(function() {
188
188
  let last = null;
189
- $base.to(
190
- Transport((v) => {
189
+ $base.pipe(
190
+ Tap((v) => {
191
191
  if (v !== last && isFilled(v)) {
192
- transport.use(v);
192
+ this.use(v);
193
193
  last = v;
194
194
  }
195
195
  })
@@ -198,14 +198,14 @@ function Memo($base) {
198
198
  }
199
199
 
200
200
  function OnlyChanged($base) {
201
- return Message((transport) => {
201
+ return Message(function() {
202
202
  let first = false;
203
- $base.to(
204
- Transport((v) => {
203
+ $base.pipe(
204
+ Tap((v) => {
205
205
  if (first === false) {
206
206
  first = true;
207
207
  } else {
208
- transport.use(v);
208
+ this.use(v);
209
209
  }
210
210
  })
211
211
  );
@@ -225,9 +225,9 @@ class PartImpl {
225
225
  this.$base = SharedSource($base);
226
226
  this.$keyed = Shared($key);
227
227
  }
228
- to(transport) {
229
- All(this.$base, this.$keyed).to(
230
- Transport(([base, keyed]) => {
228
+ pipe(transport) {
229
+ All(this.$base, this.$keyed).pipe(
230
+ Tap(([base, keyed]) => {
231
231
  const keys = keyed.split(".");
232
232
  let value = base;
233
233
  keys.forEach((key) => {
@@ -255,16 +255,16 @@ class PartImpl {
255
255
 
256
256
  function Path($base, _keyed) {
257
257
  const $keyed = ActualMessage(_keyed);
258
- return Message((transport) => {
259
- All($base, $keyed).to(
260
- Transport(([base, keyed]) => {
258
+ return Message(function() {
259
+ All($base, $keyed).pipe(
260
+ Tap(([base, keyed]) => {
261
261
  const keys = keyed.split(".");
262
262
  let value = base;
263
263
  keys.forEach((key) => {
264
264
  value = value[key];
265
265
  });
266
266
  if (value !== void 0 && value !== base) {
267
- transport.use(value);
267
+ this.use(value);
268
268
  }
269
269
  })
270
270
  );
@@ -272,24 +272,24 @@ function Path($base, _keyed) {
272
272
  }
273
273
 
274
274
  function Polling($base, $trigger) {
275
- return Message((transport) => {
276
- $trigger.to(
277
- Transport(() => {
278
- $base.to(transport);
275
+ return Message(function() {
276
+ $trigger.pipe(
277
+ Tap(() => {
278
+ $base.pipe(this);
279
279
  })
280
280
  );
281
281
  });
282
282
  }
283
283
 
284
284
  function Shot($target, $trigger) {
285
- return Message((transport) => {
285
+ return Message(function() {
286
286
  const targetSync = Primitive($target);
287
287
  targetSync.primitive();
288
- $trigger.to(
289
- Transport(() => {
288
+ $trigger.pipe(
289
+ Tap(() => {
290
290
  const value = targetSync.primitive();
291
291
  if (isFilled(value)) {
292
- transport.use(value);
292
+ this.use(value);
293
293
  }
294
294
  })
295
295
  );
@@ -297,7 +297,7 @@ function Shot($target, $trigger) {
297
297
  }
298
298
 
299
299
  function Task(baseSrc, delay = 0) {
300
- return Message((transport) => {
300
+ return Message(function() {
301
301
  let prevTimer = null;
302
302
  ExecutorApplied(baseSrc, (fn) => {
303
303
  return (v) => {
@@ -308,12 +308,12 @@ function Task(baseSrc, delay = 0) {
308
308
  fn(v);
309
309
  }, delay);
310
310
  };
311
- }).to(transport);
311
+ }).pipe(this);
312
312
  });
313
313
  }
314
314
 
315
315
  function Tick($base) {
316
- return Message((transport) => {
316
+ return Message(function() {
317
317
  let microtaskScheduled = false;
318
318
  let lastValue = null;
319
319
  const scheduleMicrotask = () => {
@@ -321,13 +321,13 @@ function Tick($base) {
321
321
  queueMicrotask(() => {
322
322
  microtaskScheduled = false;
323
323
  if (lastValue !== null) {
324
- transport.use(lastValue);
324
+ this.use(lastValue);
325
325
  lastValue = null;
326
326
  }
327
327
  });
328
328
  };
329
- $base.to(
330
- Transport((v) => {
329
+ $base.pipe(
330
+ Tap((v) => {
331
331
  lastValue = v;
332
332
  if (!microtaskScheduled) {
333
333
  scheduleMicrotask();
@@ -338,17 +338,17 @@ function Tick($base) {
338
338
  }
339
339
 
340
340
  function Transaction($base, builder, ...args) {
341
- return Message((transport) => {
341
+ return Message(function() {
342
342
  const $res = LateShared();
343
343
  const destructors = [];
344
- $base.to(
345
- Transport((v) => {
344
+ $base.pipe(
345
+ Tap((v) => {
346
346
  const $msg = builder(Of(v), ...args.map((a) => Detached(a)));
347
347
  destructors.push($msg);
348
- $msg.to($res);
348
+ $msg.pipe($res);
349
349
  })
350
350
  );
351
- $res.to(transport);
351
+ $res.pipe(this);
352
352
  return () => {
353
353
  destructors.forEach((d) => d?.destroy());
354
354
  destructors.length = 0;
@@ -357,42 +357,42 @@ function Transaction($base, builder, ...args) {
357
357
  }
358
358
 
359
359
  function HashTable($base) {
360
- return Message((transport) => {
360
+ return Message(function() {
361
361
  const record = {};
362
- $base.to(
363
- Transport(([key, value]) => {
362
+ $base.pipe(
363
+ Tap(([key, value]) => {
364
364
  record[key] = value;
365
- transport.use(record);
365
+ this.use(record);
366
366
  })
367
367
  );
368
368
  });
369
369
  }
370
370
 
371
371
  function Record(record) {
372
- return Message((transport) => {
372
+ return Message(function() {
373
373
  const keys = Object.keys(record);
374
374
  keys.forEach((key) => {
375
375
  if (!isMessage(record[key])) {
376
376
  record[key] = Of(record[key]);
377
377
  }
378
378
  });
379
- All(...Object.values(record)).to(
380
- Transport((entries) => {
379
+ All(...Object.values(record)).pipe(
380
+ Tap((entries) => {
381
381
  const record2 = {};
382
382
  entries.forEach((entry, index) => {
383
383
  record2[keys[index]] = entry;
384
384
  });
385
- transport.use(record2);
385
+ this.use(record2);
386
386
  })
387
387
  );
388
388
  });
389
389
  }
390
390
 
391
391
  function Concatenated(sources, joinPartSrc = Of("")) {
392
- return Message((transport) => {
393
- All(joinPartSrc, ...sources).to(
394
- Transport(([joinPart, ...strings]) => {
395
- transport.use(strings.join(joinPart));
392
+ return Message(function() {
393
+ All(joinPartSrc, ...sources).pipe(
394
+ Tap(([joinPart, ...strings]) => {
395
+ this.use(strings.join(joinPart));
396
396
  })
397
397
  );
398
398
  });
@@ -413,7 +413,7 @@ class TemplateImpl {
413
413
  $TPL: Of("$TPL")
414
414
  });
415
415
  }
416
- to(transport) {
416
+ pipe(transport) {
417
417
  const $vars = Record(this.vars);
418
418
  Applied(All(this.$src, this.$places, $vars), ([base, rules, vars]) => {
419
419
  Object.entries(rules).forEach(([ph, val]) => {
@@ -423,7 +423,7 @@ class TemplateImpl {
423
423
  base = base.replaceAll(ph, String(val));
424
424
  });
425
425
  return base;
426
- }).to(transport);
426
+ }).pipe(transport);
427
427
  return this;
428
428
  }
429
429
  template(value) {
@@ -449,20 +449,20 @@ class TemplateImpl {
449
449
  }
450
450
 
451
451
  function RegexpMatched(patternSrc, valueSrc, flagsSrc = Of("")) {
452
- return Message((transport) => {
453
- All(patternSrc, valueSrc, flagsSrc).to(
454
- Transport(([pattern, value, flags]) => {
455
- transport.use(new RegExp(pattern, flags).test(value));
452
+ return Message(function() {
453
+ All(patternSrc, valueSrc, flagsSrc).pipe(
454
+ Tap(([pattern, value, flags]) => {
455
+ this.use(new RegExp(pattern, flags).test(value));
456
456
  })
457
457
  );
458
458
  });
459
459
  }
460
460
 
461
461
  function RegexpReplaced(valueSrc, patternSrc, replaceValueSrc, flagsSrc = Of("")) {
462
- return Message((transport) => {
463
- All(patternSrc, valueSrc, replaceValueSrc, flagsSrc).to(
464
- Transport(([pattern, value, replaceValue, flags]) => {
465
- transport.use(
462
+ return Message(function() {
463
+ All(patternSrc, valueSrc, replaceValueSrc, flagsSrc).pipe(
464
+ Tap(([pattern, value, replaceValue, flags]) => {
465
+ this.use(
466
466
  String(value).replace(new RegExp(pattern, flags), replaceValue)
467
467
  );
468
468
  })
@@ -471,35 +471,35 @@ function RegexpReplaced(valueSrc, patternSrc, replaceValueSrc, flagsSrc = Of("")
471
471
  }
472
472
 
473
473
  function RegexpMatch(patternSrc, valueSrc, flagsSrc = Of("")) {
474
- return Message((transport) => {
475
- All(patternSrc, valueSrc, flagsSrc).to(
476
- Transport(([pattern, value, flags]) => {
474
+ return Message(function() {
475
+ All(patternSrc, valueSrc, flagsSrc).pipe(
476
+ Tap(([pattern, value, flags]) => {
477
477
  const result = new RegExp(pattern, flags).exec(value);
478
- transport.use(result ?? []);
478
+ this.use(result ?? []);
479
479
  })
480
480
  );
481
481
  });
482
482
  }
483
483
 
484
484
  function Set(baseSrc, keySrc, valueSrc) {
485
- return Message((transport) => {
486
- All(baseSrc, keySrc, valueSrc).to(
487
- Transport(([base, key, value]) => {
485
+ return Message(function() {
486
+ All(baseSrc, keySrc, valueSrc).pipe(
487
+ Tap(([base, key, value]) => {
488
488
  base[key] = value;
489
- transport.use(base);
489
+ this.use(base);
490
490
  })
491
491
  );
492
492
  });
493
493
  }
494
494
 
495
495
  function Router($url, $routes, $default) {
496
- return Message((transport) => {
496
+ return Message(function() {
497
497
  const dc = DestroyContainer();
498
498
  const destructor = () => {
499
499
  dc.destroy();
500
500
  };
501
- All($routes, $url).to(
502
- Transport(([routes, url]) => {
501
+ All($routes, $url).pipe(
502
+ Tap(([routes, url]) => {
503
503
  destructor();
504
504
  const $matches = All(
505
505
  ...routes.map(
@@ -510,18 +510,18 @@ function Router($url, $routes, $default) {
510
510
  )
511
511
  )
512
512
  );
513
- $matches.to(
514
- Transport((matches) => {
513
+ $matches.pipe(
514
+ Tap((matches) => {
515
515
  const index = matches.findIndex((v) => v === true);
516
516
  if (index === -1) {
517
517
  const instance = $default.use();
518
518
  dc.add(instance);
519
- instance.to(transport);
519
+ instance.pipe(this);
520
520
  }
521
521
  if (index > -1) {
522
522
  const instance = routes[index].message.use();
523
523
  dc.add(instance);
524
- instance.to(transport);
524
+ instance.pipe(this);
525
525
  }
526
526
  })
527
527
  );
@@ -532,47 +532,47 @@ function Router($url, $routes, $default) {
532
532
  }
533
533
 
534
534
  function And($one, $two) {
535
- return Message((transport) => {
536
- All($one, $two).to(
537
- Transport(([one, two]) => {
538
- transport.use(one && two);
535
+ return Message(function() {
536
+ All($one, $two).pipe(
537
+ Tap(([one, two]) => {
538
+ this.use(!!(one && two));
539
539
  })
540
540
  );
541
541
  });
542
542
  }
543
543
 
544
544
  function Or($one, $two) {
545
- return Message((transport) => {
546
- All($one, $two).to(
547
- Transport(([one, two]) => {
548
- transport.use(one || two);
545
+ return Message(function() {
546
+ All($one, $two).pipe(
547
+ Tap(([one, two]) => {
548
+ this.use(!!(one || two));
549
549
  })
550
550
  );
551
551
  });
552
552
  }
553
553
 
554
554
  function Not($base) {
555
- return Message((transport) => {
556
- $base.to(
557
- Transport((v) => {
558
- transport.use(!v);
555
+ return Message(function() {
556
+ $base.pipe(
557
+ Tap((v) => {
558
+ this.use(!v);
559
559
  })
560
560
  );
561
561
  });
562
562
  }
563
563
 
564
564
  function Bool($base) {
565
- return Message((transport) => {
566
- Applied($base, Boolean).to(transport);
565
+ return Message(function() {
566
+ Applied($base, Boolean).pipe(this);
567
567
  });
568
568
  }
569
569
 
570
570
  function FromJson($json, error) {
571
- return Message((transport) => {
572
- $json.to(
573
- Transport((json) => {
571
+ return Message(function() {
572
+ $json.pipe(
573
+ Tap((json) => {
574
574
  try {
575
- transport.use(JSON.parse(json));
575
+ this.use(JSON.parse(json));
576
576
  } catch (e) {
577
577
  error?.use(new Error(`Failed to parse JSON: ${e}`));
578
578
  }
@@ -582,11 +582,11 @@ function FromJson($json, error) {
582
582
  }
583
583
 
584
584
  function ToJson($data, error) {
585
- return Message((transport) => {
586
- $data.to(
587
- Transport((data) => {
585
+ return Message(function() {
586
+ $data.pipe(
587
+ Tap((data) => {
588
588
  try {
589
- transport.use(JSON.stringify(data));
589
+ this.use(JSON.stringify(data));
590
590
  } catch {
591
591
  error?.use(new Error("Failed to convert to JSON"));
592
592
  }
@@ -596,8 +596,8 @@ function ToJson($data, error) {
596
596
  }
597
597
 
598
598
  function First($base) {
599
- return Message((transport) => {
600
- Applied($base, (a) => a[0]).to(transport);
599
+ return Message(function() {
600
+ Applied($base, (a) => a[0]).pipe(this);
601
601
  });
602
602
  }
603
603