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
@@ -4,8 +4,8 @@ import {
4
4
  Late,
5
5
  MessageType,
6
6
  SourceType,
7
- Transport,
8
- TransportType,
7
+ Tap,
8
+ TapType,
9
9
  } from "silentium";
10
10
 
11
11
  /**
@@ -39,10 +39,10 @@ class DirtySource<T> implements SourceType<T> {
39
39
  }
40
40
  }
41
41
 
42
- public to(transport: TransportType<T>) {
42
+ public pipe(transport: TapType<T>) {
43
43
  const $comparing = Applied(this.$comparing, this.cloner);
44
- All($comparing, this.$base).to(
45
- Transport(([comparing, base]) => {
44
+ All($comparing, this.$base).pipe(
45
+ Tap(([comparing, base]) => {
46
46
  if (!comparing) {
47
47
  return;
48
48
  }
@@ -1,4 +1,4 @@
1
- import { Late, Transport } from "silentium";
1
+ import { Late, Tap } from "silentium";
2
2
  import { Loading } from "../behaviors/Loading";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
@@ -7,7 +7,7 @@ test("Loading.test", () => {
7
7
  const $loadingFinish = Late();
8
8
  const $loading = Loading($loadingStart, $loadingFinish);
9
9
  const g = vi.fn();
10
- $loading.to(Transport(g));
10
+ $loading.pipe(Tap(g));
11
11
  $loadingStart.use({});
12
12
  expect(g).toHaveBeenLastCalledWith(true);
13
13
  $loadingFinish.use({});
@@ -1,4 +1,4 @@
1
- import { Message, MessageType, Transport } from "silentium";
1
+ import { Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Representation Of loading process
@@ -7,11 +7,11 @@ import { Message, MessageType, Transport } from "silentium";
7
7
  * https://silentium-lab.github.io/silentium-components/#/behaviors/loading
8
8
  */
9
9
  export function Loading(
10
- $loadingStart: MessageType<unknown>,
11
- $loadingFinish: MessageType<unknown>,
10
+ $start: MessageType<unknown>,
11
+ $finish: MessageType<unknown>,
12
12
  ) {
13
- return Message<boolean>((transport) => {
14
- $loadingStart.to(Transport(() => transport.use(true)));
15
- $loadingFinish.to(Transport(() => transport.use(false)));
13
+ return Message<boolean>(function () {
14
+ $start.pipe(Tap(() => this.use(true)));
15
+ $finish.pipe(Tap(() => this.use(false)));
16
16
  });
17
17
  }
@@ -1,4 +1,4 @@
1
- import { Late, Shared, Transport } from "silentium";
1
+ import { Late, Shared, Tap } from "silentium";
2
2
  import { Lock } from "../behaviors/Lock";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
@@ -9,7 +9,7 @@ test("Lock.test", () => {
9
9
  const ls = Lock(source, lockSrc);
10
10
  const lockedSrc = Shared(ls);
11
11
  const g = vi.fn();
12
- lockedSrc.to(Transport(g));
12
+ lockedSrc.pipe(Tap(g));
13
13
 
14
14
  expect(g).toHaveBeenLastCalledWith(1);
15
15
 
@@ -1,4 +1,4 @@
1
- import { Filtered, Message, MessageType, Transport } from "silentium";
1
+ import { Filtered, Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Allows locking messages
@@ -6,14 +6,14 @@ import { Filtered, Message, MessageType, Transport } from "silentium";
6
6
  * https://silentium-lab.github.io/silentium-components/#/behaviors/lock
7
7
  */
8
8
  export function Lock<T>($base: MessageType<T>, $lock: MessageType<boolean>) {
9
- return Message<T>((transport) => {
9
+ return Message<T>(function () {
10
10
  let locked = false;
11
- $lock.to(
12
- Transport((newLock) => {
11
+ $lock.pipe(
12
+ Tap((newLock) => {
13
13
  locked = newLock;
14
14
  }),
15
15
  );
16
16
  const i = Filtered($base, () => !locked);
17
- i.to(transport);
17
+ i.pipe(this);
18
18
  });
19
19
  }
@@ -1,4 +1,4 @@
1
- import { Late, Shared, Transport } from "silentium";
1
+ import { Late, Shared, Tap } from "silentium";
2
2
  import { Memo } from "../behaviors/Memo";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
@@ -6,11 +6,11 @@ test("Memo.test", () => {
6
6
  const l = Late<number>(1);
7
7
  const mem = Shared(Memo(l));
8
8
  const g = vi.fn();
9
- mem.to(Transport(g));
9
+ mem.pipe(Tap(g));
10
10
  let counter = 0;
11
11
 
12
- mem.to(
13
- Transport(() => {
12
+ mem.pipe(
13
+ Tap(() => {
14
14
  counter += 1;
15
15
  }),
16
16
  );
@@ -1,16 +1,16 @@
1
- import { isFilled, Message, MessageType, Transport } from "silentium";
1
+ import { isFilled, Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Didn't respond if new value Of baseSrc equals to old value
5
5
  * https://silentium-lab.github.io/silentium-components/#/behaviors/memo
6
6
  */
7
7
  export function Memo<T>($base: MessageType<T>) {
8
- return Message<T>((transport) => {
8
+ return Message<T>(function () {
9
9
  let last: T | null = null;
10
- $base.to(
11
- Transport((v) => {
10
+ $base.pipe(
11
+ Tap((v) => {
12
12
  if (v !== last && isFilled(v)) {
13
- transport.use(v);
13
+ this.use(v);
14
14
  last = v;
15
15
  }
16
16
  }),
@@ -1,4 +1,4 @@
1
- import { Late, Shared, Transport } from "silentium";
1
+ import { Late, Shared, Tap } from "silentium";
2
2
  import { OnlyChanged } from "../behaviors/OnlyChanged";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
@@ -7,12 +7,12 @@ test("OnlyChanged.test", () => {
7
7
  const changedSrc = Shared(OnlyChanged(src));
8
8
 
9
9
  const g = vi.fn();
10
- changedSrc.to(Transport(g));
10
+ changedSrc.pipe(Tap(g));
11
11
  expect(g).not.toBeCalled();
12
12
 
13
13
  src.use(2);
14
14
 
15
15
  const g2 = vi.fn();
16
- changedSrc.to(Transport(g2));
16
+ changedSrc.pipe(Tap(g2));
17
17
  expect(g2).toBeCalledWith(2);
18
18
  });
@@ -1,18 +1,18 @@
1
- import { Message, MessageType, Transport } from "silentium";
1
+ import { Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Represents source what was changed at least once
5
5
  * https://silentium-lab.github.io/silentium-components/#/behaviors/only-changed
6
6
  */
7
7
  export function OnlyChanged<T>($base: MessageType<T>) {
8
- return Message<T>((transport) => {
8
+ return Message<T>(function () {
9
9
  let first = false;
10
- $base.to(
11
- Transport((v) => {
10
+ $base.pipe(
11
+ Tap((v) => {
12
12
  if (first === false) {
13
13
  first = true;
14
14
  } else {
15
- transport.use(v);
15
+ this.use(v);
16
16
  }
17
17
  }),
18
18
  );
@@ -1,4 +1,4 @@
1
- import { Late, Of, SharedSource, Transport } from "silentium";
1
+ import { Late, Of, SharedSource, Tap } from "silentium";
2
2
  import { describe, expect, test, vi } from "vitest";
3
3
  import { Part } from "../behaviors/Part";
4
4
 
@@ -12,7 +12,7 @@ describe("Part.test", () => {
12
12
  );
13
13
  const $name = Part<string>($record, Of("name"));
14
14
  const g = vi.fn();
15
- $record.to(Transport(g));
15
+ $record.pipe(Tap(g));
16
16
  expect(g).toHaveBeenLastCalledWith({ name: "Peter", surname: "Parker" });
17
17
 
18
18
  $name.use("Shmiter");
@@ -28,7 +28,7 @@ describe("Part.test", () => {
28
28
  );
29
29
  const $name = Part<string>($record, "name");
30
30
  const g = vi.fn();
31
- $record.to(Transport(g));
31
+ $record.pipe(Tap(g));
32
32
  expect(g).toHaveBeenLastCalledWith({ name: "Peter", surname: "Parker" });
33
33
 
34
34
  $name.use("Shmiter");
@@ -8,8 +8,8 @@ import {
8
8
  Shared,
9
9
  SharedSource,
10
10
  SourceType,
11
- Transport,
12
- TransportType,
11
+ Tap,
12
+ TapType,
13
13
  } from "silentium";
14
14
 
15
15
  /**
@@ -35,9 +35,9 @@ class PartImpl<R, T extends object | Array<any>, K extends string = any>
35
35
  this.$keyed = Shared($key);
36
36
  }
37
37
 
38
- public to(transport: TransportType<R, null>): this {
39
- All(this.$base, this.$keyed).to(
40
- Transport(([base, keyed]) => {
38
+ public pipe(transport: TapType<R, null>): this {
39
+ All(this.$base, this.$keyed).pipe(
40
+ Tap(([base, keyed]) => {
41
41
  const keys = keyed.split(".");
42
42
  let value: unknown = base;
43
43
  keys.forEach((key) => {
@@ -1,4 +1,4 @@
1
- import { Of, Transport } from "silentium";
1
+ import { Of, Tap } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
3
  import { Path } from "./Path";
4
4
 
@@ -9,6 +9,6 @@ test("Path._keyRaw.test", () => {
9
9
  };
10
10
  const name = Path<string>(Of(record), "name");
11
11
  const g = vi.fn();
12
- name.to(Transport(g));
12
+ name.pipe(Tap(g));
13
13
  expect(g).toHaveBeenLastCalledWith("Peter");
14
14
  });
@@ -1,4 +1,4 @@
1
- import { Of, Transport } from "silentium";
1
+ import { Of, Tap } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
3
  import { Path } from "./Path";
4
4
 
@@ -9,6 +9,6 @@ test("Path._main.test", () => {
9
9
  };
10
10
  const name = Path<string>(Of(record), Of("name"));
11
11
  const g = vi.fn();
12
- name.to(Transport(g));
12
+ name.pipe(Tap(g));
13
13
  expect(g).toHaveBeenLastCalledWith("Peter");
14
14
  });
@@ -1,4 +1,4 @@
1
- import { Of, Transport } from "silentium";
1
+ import { Of, Tap } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
3
  import { Path } from "./Path";
4
4
 
@@ -13,6 +13,6 @@ test("Path.index.test", () => {
13
13
  };
14
14
  const bestColor = Path(Of(record), Of("colors.0"));
15
15
  const g = vi.fn();
16
- bestColor.to(Transport(g));
16
+ bestColor.pipe(Tap(g));
17
17
  expect(g).toHaveBeenLastCalledWith("blue");
18
18
  });
@@ -1,4 +1,4 @@
1
- import { Of, Transport } from "silentium";
1
+ import { Of, Tap } from "silentium";
2
2
  import { Path } from "../behaviors/Path";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
@@ -12,6 +12,6 @@ test("Path.nested.test", () => {
12
12
  };
13
13
  const typeName = Path(Of(record), Of("type.name"));
14
14
  const g = vi.fn();
15
- typeName.to(Transport(g));
15
+ typeName.pipe(Tap(g));
16
16
  expect(g).toHaveBeenLastCalledWith("spider-man");
17
17
  });
@@ -4,7 +4,7 @@ import {
4
4
  MaybeMessage,
5
5
  Message,
6
6
  MessageType,
7
- Transport,
7
+ Tap,
8
8
  } from "silentium";
9
9
 
10
10
  /**
@@ -17,16 +17,16 @@ export function Path<
17
17
  K extends string = any,
18
18
  >($base: MessageType<T>, _keyed: MaybeMessage<K>) {
19
19
  const $keyed = ActualMessage(_keyed);
20
- return Message<R>((transport) => {
21
- All($base, $keyed).to(
22
- Transport(([base, keyed]) => {
20
+ return Message<R>(function () {
21
+ All($base, $keyed).pipe(
22
+ Tap(([base, keyed]) => {
23
23
  const keys = keyed.split(".");
24
24
  let value: unknown = base;
25
25
  keys.forEach((key) => {
26
26
  value = (value as Record<string, unknown>)[key];
27
27
  });
28
28
  if (value !== undefined && value !== base) {
29
- transport.use(value as R);
29
+ this.use(value as R);
30
30
  }
31
31
  }),
32
32
  );
@@ -1,14 +1,14 @@
1
- import { Message, MessageType, Transport } from "silentium";
1
+ import { Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Active polling of $base message
5
5
  * synchronized with $trigger message
6
6
  */
7
7
  export function Polling<T>($base: MessageType<T>, $trigger: MessageType<T>) {
8
- return Message<T>((transport) => {
9
- $trigger.to(
10
- Transport(() => {
11
- $base.to(transport);
8
+ return Message<T>(function () {
9
+ $trigger.pipe(
10
+ Tap(() => {
11
+ $base.pipe(this);
12
12
  }),
13
13
  );
14
14
  });
@@ -1,4 +1,4 @@
1
- import { Late, Shared, Transport } from "silentium";
1
+ import { Late, Shared, Tap } from "silentium";
2
2
  import { Shot } from "../behaviors/Shot";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
@@ -8,7 +8,7 @@ test("Shot._main.test", () => {
8
8
 
9
9
  const $shotted = Shared(Shot($base, $trigger));
10
10
  const g = vi.fn();
11
- $shotted.to(Transport(g));
11
+ $shotted.pipe(Tap(g));
12
12
 
13
13
  $base.use(1);
14
14
  $trigger.use(1);
@@ -24,6 +24,6 @@ test("Shot._main.test", () => {
24
24
  expect(g).toHaveBeenLastCalledWith(2);
25
25
 
26
26
  const g2 = vi.fn();
27
- $shotted.to(Transport(g2));
27
+ $shotted.pipe(Tap(g2));
28
28
  expect(g2).toHaveBeenLastCalledWith(2);
29
29
  });
@@ -1,4 +1,4 @@
1
- import { Late, Shared, Transport } from "silentium";
1
+ import { Late, Shared, Tap } from "silentium";
2
2
  import { OnlyChanged } from "../behaviors/OnlyChanged";
3
3
  import { Shot } from "../behaviors/Shot";
4
4
  import { expect, test } from "vitest";
@@ -10,8 +10,8 @@ test("Shot._onlyChanged.test", () => {
10
10
 
11
11
  const vals: number[] = [];
12
12
 
13
- $result.to(
14
- Transport((v) => {
13
+ $result.pipe(
14
+ Tap((v) => {
15
15
  vals.push(v);
16
16
  }),
17
17
  );
@@ -1,24 +1,18 @@
1
- import {
2
- isFilled,
3
- Message,
4
- MessageType,
5
- Primitive,
6
- Transport,
7
- } from "silentium";
1
+ import { isFilled, Message, MessageType, Primitive, Tap } from "silentium";
8
2
 
9
3
  /**
10
4
  * Helps to represent only last fresh value Of some source, refreshing controls by shotSrc
11
5
  * https://silentium-lab.github.io/silentium-components/#/behaviors/shot
12
6
  */
13
7
  export function Shot<T>($target: MessageType<T>, $trigger: MessageType) {
14
- return Message<T>((transport) => {
8
+ return Message<T>(function () {
15
9
  const targetSync = Primitive($target);
16
10
  targetSync.primitive();
17
- $trigger.to(
18
- Transport(() => {
11
+ $trigger.pipe(
12
+ Tap(() => {
19
13
  const value = targetSync.primitive();
20
14
  if (isFilled(value)) {
21
- transport.use(value);
15
+ this.use(value);
22
16
  }
23
17
  }),
24
18
  );
@@ -1,4 +1,4 @@
1
- import { Late, Transport } from "silentium";
1
+ import { Late, Tap } from "silentium";
2
2
  import { Task } from "../behaviors/Task";
3
3
  import { afterEach, beforeEach, expect, test, vi } from "vitest";
4
4
 
@@ -15,8 +15,8 @@ test("Task delays emission", () => {
15
15
  const $trigger = Late<string>();
16
16
  const delayed = Task($trigger, 100);
17
17
  const data: string[] = [];
18
- delayed.to(
19
- Transport((v) => {
18
+ delayed.pipe(
19
+ Tap((v) => {
20
20
  data.push(v);
21
21
  }),
22
22
  );
@@ -36,8 +36,8 @@ test("Task emits only last value when multiple before delay", () => {
36
36
  const $trigger = Late<string>();
37
37
  const delayed = Task($trigger, 100);
38
38
  const data: string[] = [];
39
- delayed.to(
40
- Transport((v) => {
39
+ delayed.pipe(
40
+ Tap((v) => {
41
41
  data.push(v);
42
42
  }),
43
43
  );
@@ -6,7 +6,7 @@ import { ExecutorApplied, Message, MessageType } from "silentium";
6
6
  * a certain timer firing interval
7
7
  */
8
8
  export function Task<T>(baseSrc: MessageType<T>, delay: number = 0) {
9
- return Message<T>((transport) => {
9
+ return Message<T>(function () {
10
10
  let prevTimer: unknown | null = null;
11
11
  ExecutorApplied(baseSrc, (fn) => {
12
12
  return (v) => {
@@ -17,6 +17,6 @@ export function Task<T>(baseSrc: MessageType<T>, delay: number = 0) {
17
17
  fn(v);
18
18
  }, delay);
19
19
  };
20
- }).to(transport);
20
+ }).pipe(this);
21
21
  });
22
22
  }
@@ -1,4 +1,4 @@
1
- import { Any, Late, Shared, Transport } from "silentium";
1
+ import { Any, Late, Shared, Tap } from "silentium";
2
2
  import { Tick } from "../behaviors/Tick";
3
3
  import { afterEach, beforeEach, expect, test, vi } from "vitest";
4
4
 
@@ -17,7 +17,7 @@ test("Tick.test", async () => {
17
17
  const $tick = Shared(Tick(Any($s1, $s2)), true);
18
18
 
19
19
  const g = vi.fn();
20
- $tick.to(Transport(g));
20
+ $tick.pipe(Tap(g));
21
21
 
22
22
  $s1.use(3);
23
23
  $s2.use(4);
@@ -1,11 +1,11 @@
1
- import { Message, MessageType, Transport } from "silentium";
1
+ import { Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Accumulates the last value Of the source and returns one result once per tick
5
5
  * https://silentium-lab.github.io/silentium-components/#/behaviors/tick
6
6
  */
7
7
  export function Tick<T>($base: MessageType<T>) {
8
- return Message((transport) => {
8
+ return Message(function () {
9
9
  let microtaskScheduled = false;
10
10
  let lastValue: T | null = null;
11
11
 
@@ -14,14 +14,14 @@ export function Tick<T>($base: MessageType<T>) {
14
14
  queueMicrotask(() => {
15
15
  microtaskScheduled = false;
16
16
  if (lastValue !== null) {
17
- transport.use(lastValue);
17
+ this.use(lastValue);
18
18
  lastValue = null;
19
19
  }
20
20
  });
21
21
  };
22
22
 
23
- $base.to(
24
- Transport((v) => {
23
+ $base.pipe(
24
+ Tap((v) => {
25
25
  lastValue = v;
26
26
  if (!microtaskScheduled) {
27
27
  scheduleMicrotask();
@@ -5,7 +5,7 @@ import {
5
5
  Message,
6
6
  MessageType,
7
7
  Of,
8
- Transport,
8
+ Tap,
9
9
  } from "silentium";
10
10
  import { Detached } from "../behaviors/Detached";
11
11
 
@@ -21,18 +21,18 @@ export function Transaction<T, R = unknown>(
21
21
  >,
22
22
  ...args: MessageType[]
23
23
  ) {
24
- return Message<R>((transport) => {
24
+ return Message<R>(function () {
25
25
  const $res = LateShared<R>();
26
26
  const destructors: DestroyableType[] = [];
27
27
 
28
- $base.to(
29
- Transport((v) => {
28
+ $base.pipe(
29
+ Tap((v) => {
30
30
  const $msg = builder(Of(v), ...args.map((a) => Detached(a)));
31
31
  destructors.push($msg as unknown as DestroyableType);
32
- $msg.to($res);
32
+ $msg.pipe($res);
33
33
  }),
34
34
  );
35
- $res.to(transport);
35
+ $res.pipe(this);
36
36
 
37
37
  return () => {
38
38
  destructors.forEach((d) => d?.destroy());
@@ -1,4 +1,4 @@
1
- import { Late, Transport } from "silentium";
1
+ import { Late, Tap } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
3
  import { And } from "../boolean/And";
4
4
 
@@ -7,7 +7,7 @@ test("And.test", () => {
7
7
  const $two = Late<boolean>(false);
8
8
  const result = And($one, $two);
9
9
  const g = vi.fn();
10
- result.to(Transport(g));
10
+ result.pipe(Tap(g));
11
11
  expect(g).toHaveBeenLastCalledWith(false);
12
12
 
13
13
  $one.use(true);
@@ -1,14 +1,14 @@
1
- import { All, Message, MessageType, Transport } from "silentium";
1
+ import { All, Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Logical AND over two messages
5
5
  * https://silentium-lab.github.io/silentium-components/#/boolean/and
6
6
  */
7
7
  export function And($one: MessageType<boolean>, $two: MessageType<boolean>) {
8
- return Message<boolean>((transport) => {
9
- All($one, $two).to(
10
- Transport(([one, two]) => {
11
- transport.use(one && two);
8
+ return Message<boolean>(function () {
9
+ All($one, $two).pipe(
10
+ Tap(([one, two]) => {
11
+ this.use(!!(one && two));
12
12
  }),
13
13
  );
14
14
  });
@@ -1,9 +1,9 @@
1
- import { Of, Transport } from "silentium";
1
+ import { Of, Tap } from "silentium";
2
2
  import { Bool } from "../boolean/Bool";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Bool.test", () => {
6
6
  const o = vi.fn();
7
- Bool(Of(1)).to(Transport(o));
7
+ Bool(Of(1)).pipe(Tap(o));
8
8
  expect(o).toHaveBeenCalledWith(true);
9
9
  });
@@ -5,7 +5,7 @@ import { Applied, Message, MessageType } from "silentium";
5
5
  * https://silentium-lab.github.io/silentium-components/#/boolean/bool
6
6
  */
7
7
  export function Bool($base: MessageType) {
8
- return Message<boolean>((transport) => {
9
- Applied($base, Boolean).to(transport);
8
+ return Message<boolean>(function () {
9
+ Applied($base, Boolean).pipe(this);
10
10
  });
11
11
  }
@@ -1,4 +1,4 @@
1
- import { Late, Transport } from "silentium";
1
+ import { Late, Tap } from "silentium";
2
2
  import { Not } from "../boolean/Not";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
@@ -6,7 +6,7 @@ test("Not.test", () => {
6
6
  const one = Late<boolean>(false);
7
7
  const result = Not(one);
8
8
  const g = vi.fn();
9
- result.to(Transport(g));
9
+ result.pipe(Tap(g));
10
10
  expect(g).toHaveBeenLastCalledWith(true);
11
11
 
12
12
  one.use(true);
@@ -1,14 +1,14 @@
1
- import { Message, MessageType, Transport } from "silentium";
1
+ import { Message, MessageType, Tap } from "silentium";
2
2
 
3
3
  /**
4
4
  * Logical negation of message
5
5
  * https://silentium-lab.github.io/silentium-components/#/boolean/not
6
6
  */
7
7
  export function Not($base: MessageType<boolean>) {
8
- return Message<boolean>((transport) => {
9
- $base.to(
10
- Transport((v) => {
11
- transport.use(!v);
8
+ return Message<boolean>(function () {
9
+ $base.pipe(
10
+ Tap((v) => {
11
+ this.use(!v);
12
12
  }),
13
13
  );
14
14
  });