silentium-components 0.0.83 → 0.0.85

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 (102) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/silentium-components.cjs +326 -411
  3. package/dist/silentium-components.cjs.map +1 -1
  4. package/dist/silentium-components.d.ts +80 -87
  5. package/dist/silentium-components.js +328 -412
  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 +328 -412
  11. package/dist/silentium-components.mjs.map +1 -1
  12. package/eslint.config.mjs +26 -12
  13. package/package.json +4 -2
  14. package/rollup.config.js +2 -1
  15. package/src/behaviors/Branch._main.test.ts +4 -3
  16. package/src/behaviors/Branch._values.test.ts +3 -2
  17. package/src/behaviors/Branch.branchesDontAffectResult.test.ts +4 -3
  18. package/src/behaviors/Branch.ts +13 -21
  19. package/src/behaviors/BranchLazy._main.test.ts +5 -4
  20. package/src/behaviors/BranchLazy.ts +17 -20
  21. package/src/behaviors/Const.test.ts +6 -7
  22. package/src/behaviors/Const.ts +5 -7
  23. package/src/behaviors/Deadline._main.test.ts +5 -4
  24. package/src/behaviors/Deadline._value.test.ts +4 -3
  25. package/src/behaviors/Deadline.ts +20 -27
  26. package/src/behaviors/Deferred.test.ts +5 -4
  27. package/src/behaviors/Deferred.ts +8 -10
  28. package/src/behaviors/Detached.test.ts +4 -3
  29. package/src/behaviors/Detached.ts +2 -2
  30. package/src/behaviors/Dirty.test.ts +4 -3
  31. package/src/behaviors/Dirty.ts +18 -45
  32. package/src/behaviors/Loading.test.ts +4 -3
  33. package/src/behaviors/Loading.ts +4 -4
  34. package/src/behaviors/Lock.test.ts +4 -3
  35. package/src/behaviors/Lock.ts +6 -8
  36. package/src/behaviors/Memo.test.ts +7 -8
  37. package/src/behaviors/Memo.ts +8 -10
  38. package/src/behaviors/OnlyChanged.test.ts +5 -4
  39. package/src/behaviors/OnlyChanged.ts +9 -11
  40. package/src/behaviors/Part.test.ts +12 -15
  41. package/src/behaviors/Part.ts +23 -40
  42. package/src/behaviors/Path._keyRaw.test.ts +3 -2
  43. package/src/behaviors/Path._main.test.ts +3 -2
  44. package/src/behaviors/Path.index.test.ts +3 -2
  45. package/src/behaviors/Path.nested.test.ts +4 -3
  46. package/src/behaviors/Path.ts +11 -14
  47. package/src/behaviors/Polling.test.ts +3 -2
  48. package/src/behaviors/Polling.ts +5 -7
  49. package/src/behaviors/Shot._main.test.ts +5 -4
  50. package/src/behaviors/Shot._onlyChanged.test.ts +9 -10
  51. package/src/behaviors/Shot.ts +8 -10
  52. package/src/behaviors/Task.test.ts +9 -12
  53. package/src/behaviors/Task.ts +11 -5
  54. package/src/behaviors/Tick.test.ts +5 -4
  55. package/src/behaviors/Tick.ts +9 -11
  56. package/src/behaviors/index.ts +0 -1
  57. package/src/boolean/And.test.ts +3 -2
  58. package/src/boolean/And.ts +5 -7
  59. package/src/boolean/Bool.test.ts +4 -3
  60. package/src/boolean/Bool.ts +2 -2
  61. package/src/boolean/Not.test.ts +4 -3
  62. package/src/boolean/Not.ts +5 -7
  63. package/src/boolean/Or.test.ts +4 -3
  64. package/src/boolean/Or.ts +5 -7
  65. package/src/boolean/index.ts +2 -2
  66. package/src/formats/FromJson.test.ts +2 -1
  67. package/src/formats/FromJson.ts +9 -12
  68. package/src/formats/ToJson.test.ts +1 -0
  69. package/src/formats/ToJson.ts +10 -12
  70. package/src/index.ts +4 -4
  71. package/src/lists/First.test.ts +3 -2
  72. package/src/lists/First.ts +2 -2
  73. package/src/navigation/Router._destroy.test.ts +14 -24
  74. package/src/navigation/Router._firstMatch.test.ts +7 -13
  75. package/src/navigation/Router._main.test.ts +7 -13
  76. package/src/navigation/Router._nested.test.ts +19 -30
  77. package/src/navigation/Router.ts +30 -34
  78. package/src/strings/Concatenated.test.ts +4 -3
  79. package/src/strings/Concatenated.ts +5 -7
  80. package/src/strings/Template._main.test.ts +5 -4
  81. package/src/strings/Template._place.test.ts +4 -3
  82. package/src/strings/Template.ts +21 -9
  83. package/src/structures/HashTable.test.ts +4 -3
  84. package/src/structures/HashTable.ts +6 -8
  85. package/src/structures/Record._main.test.ts +3 -2
  86. package/src/structures/Record._mixed.test.ts +3 -2
  87. package/src/structures/Record.concatenated.test.ts +7 -8
  88. package/src/structures/Record.nested.test.ts +3 -2
  89. package/src/structures/Record.ts +10 -14
  90. package/src/system/RegexpMatch._group.test.ts +3 -2
  91. package/src/system/RegexpMatch._main.test.ts +3 -2
  92. package/src/system/RegexpMatch.ts +12 -11
  93. package/src/system/RegexpMatched.test.ts +4 -3
  94. package/src/system/RegexpMatched.ts +11 -10
  95. package/src/system/RegexpReplaced.test.ts +4 -3
  96. package/src/system/RegexpReplaced.ts +6 -8
  97. package/src/system/Set.test.ts +4 -3
  98. package/src/system/Set.ts +9 -8
  99. package/src/system/index.ts +1 -1
  100. package/src/behaviors/Branch.dontRespondAfterRespond.test.ts +0 -35
  101. package/src/behaviors/Transaction.test.ts +0 -44
  102. package/src/behaviors/Transaction.ts +0 -42
@@ -1,12 +1,6 @@
1
- import {
2
- Applied,
3
- Late,
4
- Of,
5
- Shared,
6
- Tap,
7
- TapMessage,
8
- } from "silentium";
1
+ import { Applied, Late, Of, Shared } from "silentium";
9
2
  import { expect, test, vi } from "vitest";
3
+
10
4
  import { Router } from "../navigation/Router";
11
5
 
12
6
  const drop = (dropPart: string) => (value: string) => {
@@ -17,7 +11,7 @@ test("Router first matching route responds, not subsequent matches", () => {
17
11
  const $url = Late<string>("http://domain.com/page/general");
18
12
  const $urlPath = Shared(Applied($url, drop("http://domain.com")));
19
13
  const g = vi.fn();
20
- $urlPath.pipe(Tap(g));
14
+ $urlPath.then(g);
21
15
 
22
16
  const firstRouteMock = vi.fn(() => Of("first-route-response"));
23
17
  const secondRouteMock = vi.fn(() => Of("second-route-response"));
@@ -27,17 +21,17 @@ test("Router first matching route responds, not subsequent matches", () => {
27
21
  Of([
28
22
  {
29
23
  pattern: "^/page/.*", // This matches /page/anything
30
- message: TapMessage(firstRouteMock),
24
+ message: firstRouteMock,
31
25
  },
32
26
  {
33
27
  pattern: "^/page/specific$", // This also matches /page/specific
34
- message: TapMessage(secondRouteMock),
28
+ message: secondRouteMock,
35
29
  },
36
30
  ]),
37
- TapMessage(() => Of<string>("page/404.html")),
31
+ () => Of<string>("page/404.html"),
38
32
  );
39
33
  const g2 = vi.fn();
40
- $router.pipe(Tap(g2));
34
+ $router.then(g2);
41
35
 
42
36
  // Initial URL should match first route
43
37
  expect(g2).toHaveBeenLastCalledWith("first-route-response");
@@ -1,12 +1,6 @@
1
- import {
2
- Applied,
3
- Late,
4
- Of,
5
- Shared,
6
- Tap,
7
- TapMessage,
8
- } from "silentium";
1
+ import { Applied, Late, Of, Shared } from "silentium";
9
2
  import { expect, test, vi } from "vitest";
3
+
10
4
  import { Router } from "../navigation/Router";
11
5
 
12
6
  const drop = (dropPart: string) => (value: string) => {
@@ -17,24 +11,24 @@ test("Router._main.test", () => {
17
11
  const $url = Late<string>("http://domain.com/");
18
12
  const $urlPath = Shared(Applied($url, drop("http://domain.com")));
19
13
  const g = vi.fn();
20
- $urlPath.pipe(Tap(g));
14
+ $urlPath.then(g);
21
15
 
22
16
  const $router = Router(
23
17
  $urlPath,
24
18
  Of([
25
19
  {
26
20
  pattern: "^/$",
27
- message: TapMessage(() => Of("page/home.html")),
21
+ message: () => Of("page/home.html"),
28
22
  },
29
23
  {
30
24
  pattern: "/some/contacts",
31
- message: TapMessage(() => Of("page/contacts.html")),
25
+ message: () => Of("page/contacts.html"),
32
26
  },
33
27
  ]),
34
- TapMessage(() => Of<string>("page/404.html")),
28
+ () => Of<string>("page/404.html"),
35
29
  );
36
30
  const g2 = vi.fn();
37
- $router.pipe(Tap(g2));
31
+ $router.then(g2);
38
32
 
39
33
  expect(g2).toHaveBeenLastCalledWith("page/home.html");
40
34
 
@@ -1,11 +1,6 @@
1
- import {
2
- LateShared,
3
- Message,
4
- Of,
5
- Tap,
6
- TapMessage,
7
- } from "silentium";
1
+ import { LateShared, Message, Of } from "silentium";
8
2
  import { describe, expect, test } from "vitest";
3
+
9
4
  import { Detached } from "../behaviors/Detached";
10
5
  import { Router } from "../navigation/Router";
11
6
 
@@ -17,11 +12,11 @@ describe("Router._nested.test", () => {
17
12
  Of([
18
13
  {
19
14
  pattern: "^/$",
20
- message: TapMessage(() => Of<string>("home")),
15
+ message: () => Of<string>("home"),
21
16
  },
22
17
  {
23
18
  pattern: "/admin.*",
24
- message: TapMessage(() => {
19
+ message: () => {
25
20
  return Message((transport) => {
26
21
  // need to replace with detached component
27
22
  const localUrlSrc = Detached($url);
@@ -31,19 +26,19 @@ describe("Router._nested.test", () => {
31
26
  Of([
32
27
  {
33
28
  pattern: "^/admin/articles$",
34
- message: TapMessage(() => Of("articles list")),
29
+ message: () => Of("articles list"),
35
30
  },
36
31
  {
37
32
  pattern: "^/admin/articles/create$",
38
- message: TapMessage(() => Of("articles create")),
33
+ message: () => Of("articles create"),
39
34
  },
40
35
  {
41
36
  pattern: "^/admin/articles/update$",
42
- message: TapMessage(() => Of("articles update")),
37
+ message: () => Of("articles update"),
43
38
  },
44
39
  {
45
40
  pattern: "^/admin/nested/.*$",
46
- message: TapMessage(() => {
41
+ message: () => {
47
42
  return Message((transport) => {
48
43
  const localUrlSrc = Detached($url);
49
44
 
@@ -52,45 +47,39 @@ describe("Router._nested.test", () => {
52
47
  Of([
53
48
  {
54
49
  pattern: "^/admin/nested/list$",
55
- message: TapMessage(() =>
56
- Of("admin nested list"),
57
- ),
50
+ message: () => Of("admin nested list"),
58
51
  },
59
52
  ]),
60
- TapMessage(() =>
61
- Of<string>("admin nested not found"),
62
- ),
53
+ () => Of<string>("admin nested not found"),
63
54
  );
64
55
 
65
- r.pipe(transport);
56
+ r.then(transport);
66
57
 
67
58
  return function AdminDestroy() {
68
59
  r.destroy();
69
60
  };
70
61
  });
71
- }),
62
+ },
72
63
  },
73
64
  ]),
74
- TapMessage(() => Of<string>("admin not found")),
65
+ () => Of<string>("admin not found"),
75
66
  );
76
67
 
77
- r.pipe(transport);
68
+ r.then(transport);
78
69
 
79
70
  return function AdminDestroy() {
80
71
  r.destroy();
81
72
  };
82
73
  });
83
- }),
74
+ },
84
75
  },
85
76
  ]),
86
- TapMessage(() => Of("not found")),
77
+ () => Of("not found"),
87
78
  );
88
79
  const d: string[] = [];
89
- $router.pipe(
90
- Tap((v) => {
91
- d.push(v);
92
- }),
93
- );
80
+ $router.then((v) => {
81
+ d.push(v);
82
+ });
94
83
  const pd = () => d.join("\n");
95
84
 
96
85
  $url.use("/admin/articles");
@@ -1,66 +1,62 @@
1
1
  import {
2
2
  All,
3
+ ConstructorType,
3
4
  DestroyableType,
4
5
  DestroyContainer,
5
6
  Message,
6
7
  MessageType,
7
8
  Of,
8
- Tap,
9
- TapType,
10
9
  } from "silentium";
10
+
11
11
  import { RegexpMatched } from "../system";
12
12
 
13
13
  export interface Route<T> {
14
14
  pattern: string;
15
15
  patternFlags?: string;
16
- message: TapType<void, MessageType<T>>;
16
+ message: ConstructorType<[], MessageType<T>>;
17
17
  }
18
18
 
19
19
  /**
20
20
  * Router component what will return template if url matches pattern
21
21
  * https://silentium-lab.github.io/silentium-components/#/navigation/router
22
22
  */
23
- export function Router<T = "string">(
23
+ export function Router<T = string>(
24
24
  $url: MessageType<string>,
25
25
  $routes: MessageType<Route<T>[]>,
26
- $default: TapType<void, MessageType<T>>,
26
+ $default: ConstructorType<[], MessageType<T>>,
27
27
  ): MessageType<T> & DestroyableType {
28
- return Message<T>(function () {
28
+ return Message<T>(function RouterImpl(r) {
29
29
  const dc = DestroyContainer();
30
30
  const destructor = () => {
31
31
  dc.destroy();
32
32
  };
33
- All($routes, $url).pipe(
34
- Tap(([routes, url]) => {
35
- destructor();
36
- const $matches = All(
37
- ...routes.map((r) =>
38
- RegexpMatched(
39
- Of(r.pattern),
40
- Of(url),
41
- r.patternFlags ? Of(r.patternFlags) : undefined,
42
- ),
33
+ All($routes, $url).then(([routes, url]) => {
34
+ destructor();
35
+ const $matches = All(
36
+ ...routes.map((r) =>
37
+ RegexpMatched(
38
+ Of(r.pattern),
39
+ Of(url),
40
+ r.patternFlags ? Of(r.patternFlags) : undefined,
43
41
  ),
44
- );
45
- $matches.pipe(
46
- Tap((matches) => {
47
- const index = matches.findIndex((v) => v === true);
42
+ ),
43
+ );
44
+ $matches.then((matches) => {
45
+ const index = matches.findIndex((v) => v === true);
48
46
 
49
- if (index === -1) {
50
- const instance = $default.use();
51
- dc.add(instance);
52
- instance.pipe(this);
53
- }
47
+ if (index === -1) {
48
+ const instance = $default();
49
+ dc.add(instance);
50
+ instance.then(r);
51
+ }
54
52
 
55
- if (index > -1) {
56
- const instance = routes[index].message.use();
57
- dc.add(instance);
58
- instance.pipe(this);
59
- }
60
- }),
61
- );
62
- }),
63
- );
53
+ if (index > -1) {
54
+ const instance = routes[index].message();
55
+ dc.add(instance);
56
+ instance.then(r);
57
+ }
58
+ });
59
+ });
64
60
 
65
61
  return destructor;
66
62
  });
@@ -1,14 +1,15 @@
1
- import { Of, Tap } from "silentium";
2
- import { Concatenated } from "../strings/Concatenated";
1
+ import { Of } from "silentium";
3
2
  import { expect, test, vi } from "vitest";
4
3
 
4
+ import { Concatenated } from "../strings/Concatenated";
5
+
5
6
  test("Concatenated.test", () => {
6
7
  const $concatenated = Concatenated(
7
8
  [Of("one"), Of("two"), Of("three")],
8
9
  Of("-"),
9
10
  );
10
11
  const g = vi.fn();
11
- $concatenated.pipe(Tap(g));
12
+ $concatenated.then(g);
12
13
 
13
14
  expect(g).toHaveBeenLastCalledWith("one-two-three");
14
15
  });
@@ -1,4 +1,4 @@
1
- import { All, Message, MessageType, Of, Tap } from "silentium";
1
+ import { All, Message, MessageType, Of } from "silentium";
2
2
 
3
3
  /**
4
4
  * Join sources Of strings to one source
@@ -8,11 +8,9 @@ export function Concatenated(
8
8
  sources: MessageType<string>[],
9
9
  joinPartSrc: MessageType<string> = Of(""),
10
10
  ) {
11
- return Message<string>(function () {
12
- All(joinPartSrc, ...sources).pipe(
13
- Tap(([joinPart, ...strings]) => {
14
- this.use(strings.join(joinPart));
15
- }),
16
- );
11
+ return Message<string>(function ConcatenatedImpl(r) {
12
+ All(joinPartSrc, ...sources).then(([joinPart, ...strings]) => {
13
+ r(strings.join(joinPart));
14
+ });
17
15
  });
18
16
  }
@@ -1,7 +1,8 @@
1
- import { Of, Tap } from "silentium";
1
+ import { Of } from "silentium";
2
+ import { expect, test, vi } from "vitest";
3
+
2
4
  import { Template } from "../strings/Template";
3
5
  import { Record } from "../structures";
4
- import { expect, test, vi } from "vitest";
5
6
 
6
7
  test("Template._main.test", () => {
7
8
  const tpl = Template(
@@ -11,7 +12,7 @@ test("Template._main.test", () => {
11
12
  }),
12
13
  );
13
14
  const g = vi.fn();
14
- tpl.pipe(Tap(g));
15
+ tpl.then(g);
15
16
 
16
17
  expect(g).toHaveBeenLastCalledWith("<h1>one value</h1>");
17
18
 
@@ -22,7 +23,7 @@ test("Template._main.test", () => {
22
23
  }),
23
24
  );
24
25
  const g2 = vi.fn();
25
- tpl2.pipe(Tap(g2));
26
+ tpl2.then(g2);
26
27
 
27
28
  expect(g2).toHaveBeenLastCalledWith("<h2>second value</h2>");
28
29
  });
@@ -1,12 +1,13 @@
1
- import { Of, Tap } from "silentium";
2
- import { Template } from "../strings/Template";
1
+ import { Of } from "silentium";
3
2
  import { expect, test, vi } from "vitest";
4
3
 
4
+ import { Template } from "../strings/Template";
5
+
5
6
  test("Template._place.test", () => {
6
7
  const t = Template();
7
8
  t.template(`<div class="greeting">Hello ${t.var(Of("User"))}</div>`);
8
9
  const g = vi.fn();
9
- t.pipe(Tap(g));
10
+ t.then(g);
10
11
 
11
12
  expect(g).toHaveBeenLastCalledWith('<div class="greeting">Hello User</div>');
12
13
  });
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  All,
3
3
  Applied,
4
+ ConstructorType,
4
5
  DestroyableType,
5
6
  DestroyContainer,
6
7
  isDestroyable,
7
8
  MessageType,
8
9
  Of,
9
- TapType,
10
+ Rejections,
10
11
  } from "silentium";
12
+
11
13
  import { Record } from "../structures";
12
14
 
13
15
  /**
@@ -24,6 +26,7 @@ export function Template(
24
26
 
25
27
  class TemplateImpl implements MessageType<string>, DestroyableType {
26
28
  private dc = DestroyContainer();
29
+ private rejections = new Rejections();
27
30
  private vars: Record<string, MessageType> = {
28
31
  $TPL: Of("$TPL"),
29
32
  };
@@ -33,18 +36,22 @@ class TemplateImpl implements MessageType<string>, DestroyableType {
33
36
  private $places: MessageType<Record<string, unknown>> = Of({}),
34
37
  ) {}
35
38
 
36
- public pipe(transport: TapType<string>): this {
39
+ public then(transport: ConstructorType<[string]>): this {
37
40
  const $vars = Record(this.vars);
38
41
  Applied(All(this.$src, this.$places, $vars), ([base, rules, vars]) => {
39
- Object.entries(rules).forEach(([ph, val]) => {
40
- base = base.replaceAll(ph, String(val));
41
- });
42
- Object.entries(vars).forEach(([ph, val]) => {
43
- base = base.replaceAll(ph, String(val));
44
- });
42
+ try {
43
+ Object.entries(rules).forEach(([ph, val]) => {
44
+ base = base.replaceAll(ph, String(val));
45
+ });
46
+ Object.entries(vars).forEach(([ph, val]) => {
47
+ base = base.replaceAll(ph, String(val));
48
+ });
49
+ } catch (e) {
50
+ this.rejections.reject(e);
51
+ }
45
52
 
46
53
  return base;
47
- }).pipe(transport);
54
+ }).then(transport);
48
55
  return this;
49
56
  }
50
57
 
@@ -66,6 +73,11 @@ class TemplateImpl implements MessageType<string>, DestroyableType {
66
73
  return varName;
67
74
  }
68
75
 
76
+ public catch(rejected: ConstructorType<[unknown]>): this {
77
+ this.rejections.catch(rejected);
78
+ return this;
79
+ }
80
+
69
81
  public destroy(): this {
70
82
  this.dc.destroy();
71
83
  return this;
@@ -1,12 +1,13 @@
1
- import { Late, Tap } from "silentium";
2
- import { HashTable } from "../structures/HashTable";
1
+ import { Late } from "silentium";
3
2
  import { expect, test, vi } from "vitest";
4
3
 
4
+ import { HashTable } from "../structures/HashTable";
5
+
5
6
  test("HashTable.test", () => {
6
7
  const $entry = Late<[string, string]>();
7
8
  const $hash = HashTable($entry);
8
9
  const g = vi.fn();
9
- $hash.pipe(Tap(g));
10
+ $hash.then(g);
10
11
  $entry.use(["key-one", "value-one"]);
11
12
  $entry.use(["key-two", "value-two"]);
12
13
 
@@ -1,4 +1,4 @@
1
- import { Message, MessageType, Tap } from "silentium";
1
+ import { Message, MessageType } from "silentium";
2
2
 
3
3
  /**
4
4
  * By receiving a message with a key and value, collects a table
@@ -6,14 +6,12 @@ import { Message, MessageType, Tap } from "silentium";
6
6
  * https://silentium-lab.github.io/silentium-components/#/structures/hash-table
7
7
  */
8
8
  export function HashTable<T>($base: MessageType<[string, unknown]>) {
9
- return Message<T>(function () {
9
+ return Message<T>(function HashTableImpl(r) {
10
10
  const record: Record<string, unknown> = {};
11
11
 
12
- $base.pipe(
13
- Tap(([key, value]) => {
14
- record[key] = value;
15
- this.use(record as T);
16
- }),
17
- );
12
+ $base.then(([key, value]) => {
13
+ record[key] = value;
14
+ r(record as T);
15
+ });
18
16
  });
19
17
  }
@@ -1,5 +1,6 @@
1
- import { Late, Of, Tap } from "silentium";
1
+ import { Late, Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
+
3
4
  import { Record } from "./Record";
4
5
 
5
6
  test("Record._main.test", () => {
@@ -10,7 +11,7 @@ test("Record._main.test", () => {
10
11
  three: $three,
11
12
  });
12
13
  const g = vi.fn();
13
- $record.pipe(Tap(g));
14
+ $record.then(g);
14
15
 
15
16
  expect(g).toHaveBeenLastCalledWith({
16
17
  one: "one",
@@ -1,5 +1,6 @@
1
- import { Late, Tap } from "silentium";
1
+ import { Late } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
+
3
4
  import { Record } from "./Record";
4
5
 
5
6
  test("Record._mixed.test", () => {
@@ -10,7 +11,7 @@ test("Record._mixed.test", () => {
10
11
  three: $three,
11
12
  });
12
13
  const g = vi.fn();
13
- $record.pipe(Tap(g));
14
+ $record.then(g);
14
15
 
15
16
  expect(g).toHaveBeenLastCalledWith({
16
17
  one: "one",
@@ -1,7 +1,8 @@
1
- import { Late, Of, Shared, Tap } from "silentium";
1
+ import { Late, Of, Shared } from "silentium";
2
+ import { expect, test, vi } from "vitest";
3
+
2
4
  import { Concatenated } from "../strings";
3
5
  import { Record } from "./Record";
4
- import { expect, test, vi } from "vitest";
5
6
 
6
7
  test("Record.concatenated.test", () => {
7
8
  const $three = Of<string>("three");
@@ -15,13 +16,11 @@ test("Record.concatenated.test", () => {
15
16
  }),
16
17
  );
17
18
  const g = vi.fn();
18
- r.pipe(Tap(g));
19
+ r.then(g);
19
20
  let counter = 0;
20
- r.pipe(
21
- Tap(() => {
22
- counter += 1;
23
- }),
24
- );
21
+ r.then(() => {
22
+ counter += 1;
23
+ });
25
24
 
26
25
  expect(g).toHaveBeenLastCalledWith({
27
26
  one: "one",
@@ -1,5 +1,6 @@
1
- import { Of, Tap } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
+
3
4
  import { Record } from "./Record";
4
5
 
5
6
  test("Record.nested.test", () => {
@@ -14,7 +15,7 @@ test("Record.nested.test", () => {
14
15
  }),
15
16
  });
16
17
  const g = vi.fn();
17
- $record.pipe(Tap(g));
18
+ $record.then(g);
18
19
 
19
20
  expect(g).toHaveBeenLastCalledWith({
20
21
  one: "one",
@@ -1,4 +1,4 @@
1
- import { All, isMessage, Message, MessageType, Of, Tap } from "silentium";
1
+ import { ActualMessage, All, Message, MessageType } from "silentium";
2
2
 
3
3
  type UnWrap<T> = T extends MessageType<infer U> ? U : T;
4
4
 
@@ -7,21 +7,17 @@ type UnWrap<T> = T extends MessageType<infer U> ? U : T;
7
7
  * https://silentium-lab.github.io/silentium-components/#/structures/record
8
8
  */
9
9
  export function Record<T>(record: Record<string, T>) {
10
- return Message<Record<string, UnWrap<T>>>(function () {
10
+ return Message<Record<string, UnWrap<T>>>(function RecordImpl(r) {
11
11
  const keys = Object.keys(record);
12
12
  keys.forEach((key) => {
13
- if (!isMessage(record[key])) {
14
- record[key] = Of(record[key]) as any;
15
- }
13
+ record[key] = ActualMessage(record[key]) as any;
14
+ });
15
+ All(...(Object.values(record) as any)).then((entries) => {
16
+ const record: Record<string, any> = {};
17
+ entries.forEach((entry, index) => {
18
+ record[keys[index]] = entry;
19
+ });
20
+ r(record);
16
21
  });
17
- All(...(Object.values(record) as any)).pipe(
18
- Tap((entries) => {
19
- const record: Record<string, any> = {};
20
- entries.forEach((entry, index) => {
21
- record[keys[index]] = entry;
22
- });
23
- this.use(record);
24
- }),
25
- );
26
22
  });
27
23
  }
@@ -1,5 +1,6 @@
1
- import { Of, Tap } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
+
3
4
  import { Path } from "../behaviors";
4
5
  import { RegexpMatch } from "./RegexpMatch";
5
6
 
@@ -7,7 +8,7 @@ test("RegexpMatch._group.test", () => {
7
8
  const $url = Of<string>("http://domain.com/some/url/");
8
9
  const $matched = Path(RegexpMatch(Of("/(s\\w+)/"), $url), Of("1"));
9
10
  const g = vi.fn();
10
- $matched.pipe(Tap(g));
11
+ $matched.then(g);
11
12
 
12
13
  expect(g).toHaveBeenLastCalledWith("some");
13
14
  });
@@ -1,5 +1,6 @@
1
- import { Of, Tap } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
+
3
4
  import { Path } from "../behaviors";
4
5
  import { RegexpMatch } from "./RegexpMatch";
5
6
 
@@ -7,7 +8,7 @@ test("RegexpMatch._main.test", () => {
7
8
  const $url = Of<string>("http://domain.com/some/url/");
8
9
  const $matched = Path(RegexpMatch(Of("/(s\\w+)/"), $url), Of("0"));
9
10
  const g = vi.fn();
10
- $matched.pipe(Tap(g));
11
+ $matched.then(g);
11
12
 
12
13
  expect(g).toHaveBeenLastCalledWith("/some/");
13
14
  });