silentium-components 0.0.65 → 0.0.67

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 +15 -0
  2. package/dist/silentium-components.cjs +215 -215
  3. package/dist/silentium-components.cjs.map +1 -1
  4. package/dist/silentium-components.d.ts +47 -47
  5. package/dist/silentium-components.js +181 -181
  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 +181 -181
  11. package/dist/silentium-components.mjs.map +1 -1
  12. package/package.json +2 -2
  13. package/src/behaviors/Branch._main.test.ts +7 -7
  14. package/src/behaviors/Branch.branchesDontAffectResult.test.ts +7 -7
  15. package/src/behaviors/Branch.dontRespondAfterRespond.test.ts +7 -7
  16. package/src/behaviors/Branch.ts +9 -9
  17. package/src/behaviors/BranchLazy._main.test.ts +7 -7
  18. package/src/behaviors/BranchLazy.ts +9 -9
  19. package/src/behaviors/Const.test.ts +4 -4
  20. package/src/behaviors/Const.ts +5 -5
  21. package/src/behaviors/Deadline._main.test.ts +4 -4
  22. package/src/behaviors/Deadline._value.test.ts +4 -4
  23. package/src/behaviors/Deadline.ts +8 -8
  24. package/src/behaviors/Deferred.test.ts +6 -6
  25. package/src/behaviors/Deferred.ts +8 -8
  26. package/src/behaviors/Detached.test.ts +4 -4
  27. package/src/behaviors/Detached.ts +4 -4
  28. package/src/behaviors/Dirty.test.ts +4 -4
  29. package/src/behaviors/Dirty.ts +9 -9
  30. package/src/behaviors/Loading.test.ts +5 -5
  31. package/src/behaviors/Loading.ts +7 -7
  32. package/src/behaviors/Lock.test.ts +6 -6
  33. package/src/behaviors/Lock.ts +7 -7
  34. package/src/behaviors/Memo.test.ts +4 -4
  35. package/src/behaviors/Memo.ts +5 -5
  36. package/src/behaviors/OnlyChanged.test.ts +4 -4
  37. package/src/behaviors/OnlyChanged.ts +4 -4
  38. package/src/behaviors/Part.test.ts +5 -5
  39. package/src/behaviors/Part.ts +10 -14
  40. package/src/behaviors/Path._main.test.ts +3 -3
  41. package/src/behaviors/Path.index.test.ts +3 -3
  42. package/src/behaviors/Path.nested.test.ts +3 -3
  43. package/src/behaviors/Path.ts +8 -12
  44. package/src/behaviors/Polling.test.ts +4 -4
  45. package/src/behaviors/Polling.ts +5 -5
  46. package/src/behaviors/Shot._main.test.ts +5 -5
  47. package/src/behaviors/Shot._onlyChanged.test.ts +6 -6
  48. package/src/behaviors/Shot.ts +8 -8
  49. package/src/behaviors/Task.ts +7 -7
  50. package/src/behaviors/Tick.test.ts +5 -5
  51. package/src/behaviors/Tick.ts +5 -5
  52. package/src/boolean/And.test.ts +5 -5
  53. package/src/boolean/And.ts +7 -7
  54. package/src/boolean/Bool.test.ts +3 -3
  55. package/src/boolean/Bool.ts +6 -6
  56. package/src/boolean/Not.test.ts +4 -4
  57. package/src/boolean/Not.ts +4 -4
  58. package/src/boolean/Or.test.ts +5 -5
  59. package/src/boolean/Or.ts +7 -7
  60. package/src/formats/FromJson.test.ts +4 -4
  61. package/src/formats/FromJson.ts +5 -5
  62. package/src/formats/ToJson.test.ts +4 -4
  63. package/src/formats/ToJson.ts +5 -5
  64. package/src/lists/First.test.ts +3 -3
  65. package/src/lists/First.ts +7 -7
  66. package/src/navigation/Router._main.test.ts +9 -9
  67. package/src/navigation/Router._nested.test.ts +20 -20
  68. package/src/navigation/Router.ts +23 -23
  69. package/src/strings/Concatenated.test.ts +5 -5
  70. package/src/strings/Concatenated.ts +9 -9
  71. package/src/strings/Template._main.test.ts +11 -11
  72. package/src/strings/Template._place.test.ts +4 -4
  73. package/src/strings/Template.ts +19 -19
  74. package/src/structures/HashTable.test.ts +4 -4
  75. package/src/structures/HashTable.ts +5 -5
  76. package/src/structures/Record._main.test.ts +6 -6
  77. package/src/structures/Record.concatenated.test.ts +10 -10
  78. package/src/structures/Record.nested.test.ts +9 -9
  79. package/src/structures/RecordOf.ts +8 -8
  80. package/src/system/RegexpMatch._group.test.ts +5 -5
  81. package/src/system/RegexpMatch._main.test.ts +5 -5
  82. package/src/system/RegexpMatch.ts +9 -9
  83. package/src/system/RegexpMatched.test.ts +4 -4
  84. package/src/system/RegexpMatched.ts +8 -8
  85. package/src/system/RegexpReplaced.test.ts +4 -4
  86. package/src/system/RegexpReplaced.ts +8 -8
  87. package/src/system/Set.test.ts +4 -4
  88. package/src/system/Set.ts +7 -7
  89. package/docs/assets/js/components/linkDynamic.mjs +0 -14
  90. package/docs/assets/js/components/linkReloadable.mjs +0 -17
  91. package/docs/assets/js/components.mjs +0 -2
  92. package/docs/assets/js/index.mjs +0 -271
@@ -1,27 +1,27 @@
1
- import { all, applied, EventType, late, SourceType } from "silentium";
1
+ import { All, Applied, EventType, Late, SourceType } from "silentium";
2
2
 
3
3
  /**
4
4
  * Takes source and remember it first value
5
5
  * returns new record, what will contain only fields what was changed
6
6
  * https://silentium-lab.github.io/silentium-components/#/behaviors/dirty
7
7
  */
8
- export const dirty = <T>(
8
+ export function Dirty<T>(
9
9
  baseEntitySource: EventType<T>,
10
10
  alwaysKeep: string[] = [],
11
11
  excludeKeys: string[] = [],
12
12
  cloneFn?: (v: T) => T,
13
- ): SourceType<T> => {
14
- const comparingSrc = late<T>();
13
+ ): SourceType<T> {
14
+ const comparingSrc = Late<T>();
15
15
 
16
16
  if (cloneFn === undefined) {
17
17
  cloneFn = (value) => JSON.parse(JSON.stringify(value));
18
18
  }
19
19
 
20
20
  return {
21
- event: (u) => {
22
- const comparingDetached = applied(comparingSrc.event, cloneFn);
21
+ event: (user) => {
22
+ const comparingDetached = Applied(comparingSrc.event, cloneFn);
23
23
 
24
- all(
24
+ All(
25
25
  comparingDetached,
26
26
  baseEntitySource,
27
27
  )(([comparing, base]) => {
@@ -29,7 +29,7 @@ export const dirty = <T>(
29
29
  return;
30
30
  }
31
31
 
32
- u(
32
+ user(
33
33
  Object.fromEntries(
34
34
  Object.entries(comparing).filter(([key, value]) => {
35
35
  if (alwaysKeep.includes(key)) {
@@ -48,4 +48,4 @@ export const dirty = <T>(
48
48
  comparingSrc.use(v);
49
49
  },
50
50
  };
51
- };
51
+ }
@@ -1,11 +1,11 @@
1
- import { late } from "silentium";
2
- import { loading } from "../behaviors/Loading";
1
+ import { Late } from "silentium";
2
+ import { Loading } from "../behaviors/Loading";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Loading.test", () => {
6
- const loadingStartSource = late();
7
- const loadingFinishSource = late();
8
- const loadingSrc = loading(
6
+ const loadingStartSource = Late();
7
+ const loadingFinishSource = Late();
8
+ const loadingSrc = Loading(
9
9
  loadingStartSource.event,
10
10
  loadingFinishSource.event,
11
11
  );
@@ -1,17 +1,17 @@
1
1
  import { EventType } from "silentium";
2
2
 
3
3
  /**
4
- * Representation of loading process
4
+ * Representation Of loading process
5
5
  * first informatin source begins loading
6
6
  * second information source stops loading
7
7
  * https://silentium-lab.github.io/silentium-components/#/behaviors/loading
8
8
  */
9
- export const loading = (
9
+ export function Loading(
10
10
  loadingStartSrc: EventType<unknown>,
11
11
  loadingFinishSrc: EventType<unknown>,
12
- ): EventType<boolean> => {
13
- return (u) => {
14
- loadingStartSrc(() => u(true));
15
- loadingFinishSrc(() => u(false));
12
+ ): EventType<boolean> {
13
+ return (user) => {
14
+ loadingStartSrc(() => user(true));
15
+ loadingFinishSrc(() => user(false));
16
16
  };
17
- };
17
+ }
@@ -1,13 +1,13 @@
1
- import { late, shared } from "silentium";
2
- import { lock } from "../behaviors/Lock";
1
+ import { Late, Shared } from "silentium";
2
+ import { Lock } from "../behaviors/Lock";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Lock.test", () => {
6
- const source = late<number>(1);
7
- const lockSrc = late<boolean>(false);
6
+ const source = Late<number>(1);
7
+ const lockSrc = Late<boolean>(false);
8
8
 
9
- const ls = lock(source.event, lockSrc.event);
10
- const lockedSrc = shared(ls);
9
+ const ls = Lock(source.event, lockSrc.event);
10
+ const lockedSrc = Shared(ls);
11
11
  const g = vi.fn();
12
12
  lockedSrc.event(g);
13
13
 
@@ -1,18 +1,18 @@
1
- import { EventType, filtered } from "silentium";
1
+ import { EventType, Filtered } from "silentium";
2
2
 
3
3
  /**
4
4
  * https://silentium-lab.github.io/silentium-components/#/behaviors/lock
5
5
  */
6
- export const lock = <T>(
6
+ export function Lock<T>(
7
7
  baseSrc: EventType<T>,
8
8
  lockSrc: EventType<boolean>,
9
- ): EventType<T> => {
10
- return (u) => {
9
+ ): EventType<T> {
10
+ return (user) => {
11
11
  let locked = false;
12
12
  lockSrc((newLock) => {
13
13
  locked = newLock;
14
14
  });
15
- const i = filtered(baseSrc, () => !locked);
16
- i(u);
15
+ const i = Filtered(baseSrc, () => !locked);
16
+ i(user);
17
17
  };
18
- };
18
+ }
@@ -1,10 +1,10 @@
1
- import { late, shared } from "silentium";
2
- import { memo } from "../behaviors/Memo";
1
+ import { Late, Shared } from "silentium";
2
+ import { Memo } from "../behaviors/Memo";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Memo.test", () => {
6
- const l = late<number>(1);
7
- const mem = shared(memo(l.event));
6
+ const l = Late<number>(1);
7
+ const mem = Shared(Memo(l.event));
8
8
  const g = vi.fn();
9
9
  mem.event(g);
10
10
  let counter = 0;
@@ -1,18 +1,18 @@
1
1
  import { EventType } from "silentium";
2
2
 
3
3
  /**
4
- * Didn't respond if new value of baseSrc equals to old value
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
- export const memo = <T>(baseSrc: EventType<T>): EventType<T> => {
8
- return (u) => {
7
+ export function Memo<T>(baseSrc: EventType<T>): EventType<T> {
8
+ return (user) => {
9
9
  let lastValue: T | null = null;
10
10
 
11
11
  baseSrc((v) => {
12
12
  if (v !== lastValue) {
13
- u(v);
13
+ user(v);
14
14
  lastValue = v;
15
15
  }
16
16
  });
17
17
  };
18
- };
18
+ }
@@ -1,10 +1,10 @@
1
- import { late, shared } from "silentium";
2
- import { onlyChanged } from "../behaviors/OnlyChanged";
1
+ import { Late, Shared } from "silentium";
2
+ import { OnlyChanged } from "../behaviors/OnlyChanged";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("OnlyChanged.test", () => {
6
- const src = late<number>(1);
7
- const changedSrc = shared(onlyChanged(src.event));
6
+ const src = Late<number>(1);
7
+ const changedSrc = Shared(OnlyChanged(src.event));
8
8
 
9
9
  const g = vi.fn();
10
10
  changedSrc.event(g);
@@ -4,16 +4,16 @@ import { EventType } from "silentium";
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
- export const onlyChanged = <T>(baseSrc: EventType<T>): EventType<T> => {
8
- return (u) => {
7
+ export function OnlyChanged<T>(baseSrc: EventType<T>): EventType<T> {
8
+ return (user) => {
9
9
  let firstValue = false;
10
10
 
11
11
  baseSrc((v) => {
12
12
  if (firstValue === false) {
13
13
  firstValue = true;
14
14
  } else {
15
- u(v);
15
+ user(v);
16
16
  }
17
17
  });
18
18
  };
19
- };
19
+ }
@@ -1,15 +1,15 @@
1
- import { late, of, sharedSource } from "silentium";
2
- import { part } from "../behaviors/Part";
1
+ import { Late, Of, SharedSource } from "silentium";
2
+ import { Part } from "../behaviors/Part";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Part.test", () => {
6
- const recordSrc = sharedSource(
7
- late({
6
+ const recordSrc = SharedSource(
7
+ Late({
8
8
  name: "Peter",
9
9
  surname: "Parker",
10
10
  }),
11
11
  );
12
- const nameSrc = part<string>(recordSrc, of("name"));
12
+ const nameSrc = Part<string>(recordSrc, Of("name"));
13
13
  const g = vi.fn();
14
14
  recordSrc.event(g);
15
15
  expect(g).toHaveBeenLastCalledWith({ name: "Peter", surname: "Parker" });
@@ -1,22 +1,18 @@
1
- import { all, EventType, isFilled, primitive, SourceType } from "silentium";
1
+ import { All, EventType, isFilled, Primitive, SourceType } from "silentium";
2
2
 
3
3
  /**
4
- * Return source of record path
4
+ * Return source Of record path
5
5
  * https://silentium-lab.github.io/silentium-components/#/behaviors/path
6
6
  */
7
- export const part = <
8
- R,
9
- T extends Record<string, unknown> | Array<unknown> = any,
10
- K extends string = any,
11
- >(
7
+ export function Part<R, T extends object | Array<any>, K extends string = any>(
12
8
  baseSrc: SourceType<T>,
13
9
  keySrc: EventType<K>,
14
- ): SourceType<R> => {
15
- const baseSync = primitive(baseSrc.event);
16
- const keySync = primitive(keySrc);
10
+ ): SourceType<R> {
11
+ const baseSync = Primitive(baseSrc.event);
12
+ const keySync = Primitive(keySrc);
17
13
  return {
18
- event: (u) => {
19
- all(
14
+ event: (user) => {
15
+ All(
20
16
  baseSrc.event,
21
17
  keySrc,
22
18
  )(([base, key]) => {
@@ -27,7 +23,7 @@ export const part = <
27
23
  });
28
24
 
29
25
  if (value !== undefined && value !== base) {
30
- u(value as R);
26
+ user(value as R);
31
27
  }
32
28
  });
33
29
  },
@@ -41,4 +37,4 @@ export const part = <
41
37
  }
42
38
  },
43
39
  };
44
- };
40
+ }
@@ -1,13 +1,13 @@
1
- import { of } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
- import { path } from "./Path";
3
+ import { Path } from "./Path";
4
4
 
5
5
  test("Path._main.test", () => {
6
6
  const record = {
7
7
  name: "Peter",
8
8
  surname: "Parker",
9
9
  };
10
- const name = path<string>(of(record), of("name"));
10
+ const name = Path<string>(Of(record), Of("name"));
11
11
  const g = vi.fn();
12
12
  name(g);
13
13
  expect(g).toHaveBeenLastCalledWith("Peter");
@@ -1,6 +1,6 @@
1
- import { of } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
- import { path } from "./Path";
3
+ import { Path } from "./Path";
4
4
 
5
5
  test("Path.index.test", () => {
6
6
  const record = {
@@ -11,7 +11,7 @@ test("Path.index.test", () => {
11
11
  name: "spider-man",
12
12
  },
13
13
  };
14
- const bestColor = path(of(record), of("colors.0"));
14
+ const bestColor = Path(Of(record), Of("colors.0"));
15
15
  const g = vi.fn();
16
16
  bestColor(g);
17
17
  expect(g).toHaveBeenLastCalledWith("blue");
@@ -1,5 +1,5 @@
1
- import { of } from "silentium";
2
- import { path } from "../behaviors/Path";
1
+ import { Of } from "silentium";
2
+ import { Path } from "../behaviors/Path";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Path.nested.test", () => {
@@ -10,7 +10,7 @@ test("Path.nested.test", () => {
10
10
  name: "spider-man",
11
11
  },
12
12
  };
13
- const typeName = path(of(record), of("type.name"));
13
+ const typeName = Path(Of(record), Of("type.name"));
14
14
  const g = vi.fn();
15
15
  typeName(g);
16
16
  expect(g).toHaveBeenLastCalledWith("spider-man");
@@ -1,19 +1,15 @@
1
- import { all, EventType } from "silentium";
1
+ import { All, EventType } from "silentium";
2
2
 
3
3
  /**
4
- * Return source of record path
4
+ * Return source Of record path
5
5
  * https://silentium-lab.github.io/silentium-components/#/behaviors/path
6
6
  */
7
- export const path = <
8
- R,
9
- T extends Record<string, unknown> | Array<unknown> = any,
10
- K extends string = any,
11
- >(
7
+ export function Path<R, T extends object | Array<any>, K extends string = any>(
12
8
  baseSrc: EventType<T>,
13
9
  keySrc: EventType<K>,
14
- ): EventType<R> => {
15
- return (u) => {
16
- all(
10
+ ): EventType<R> {
11
+ return (user) => {
12
+ All(
17
13
  baseSrc,
18
14
  keySrc,
19
15
  )(([base, key]) => {
@@ -24,8 +20,8 @@ export const path = <
24
20
  });
25
21
 
26
22
  if (value !== undefined && value !== base) {
27
- u(value as R);
23
+ user(value as R);
28
24
  }
29
25
  });
30
26
  };
31
- };
27
+ }
@@ -1,15 +1,15 @@
1
- import { EventType, late, primitive } from "silentium";
1
+ import { EventType, Late, Primitive } from "silentium";
2
2
  import { expect, test } from "vitest";
3
- import { polling } from "../behaviors/Polling";
3
+ import { Polling } from "../behaviors/Polling";
4
4
 
5
5
  test("Polling.test", () => {
6
- const triggerSrc = late(1);
6
+ const triggerSrc = Late(1);
7
7
  let calls = 0;
8
8
  const callsSrc: EventType<number> = (o) => {
9
9
  calls += 1;
10
10
  o(calls);
11
11
  };
12
- const s = primitive(polling(callsSrc, triggerSrc.event));
12
+ const s = Primitive(Polling(callsSrc, triggerSrc.event));
13
13
 
14
14
  expect(s.primitive()).toBe(1);
15
15
 
@@ -1,12 +1,12 @@
1
1
  import { EventType } from "silentium";
2
2
 
3
- export const polling = <T>(
3
+ export function Polling<T>(
4
4
  baseSrc: EventType<T>,
5
5
  triggerSrc: EventType<T>,
6
- ): EventType<T> => {
7
- return (u) => {
6
+ ): EventType<T> {
7
+ return (user) => {
8
8
  triggerSrc(() => {
9
- baseSrc(u);
9
+ baseSrc(user);
10
10
  });
11
11
  };
12
- };
12
+ }
@@ -1,12 +1,12 @@
1
- import { late, shared } from "silentium";
2
- import { shot } from "../behaviors/Shot";
1
+ import { Late, Shared } from "silentium";
2
+ import { Shot } from "../behaviors/Shot";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Shot._main.test", () => {
6
- const baseSrc = late();
7
- const shotSrc = late();
6
+ const baseSrc = Late();
7
+ const shotSrc = Late();
8
8
 
9
- const shotResult = shared(shot(baseSrc.event, shotSrc.event));
9
+ const shotResult = Shared(Shot(baseSrc.event, shotSrc.event));
10
10
  const g = vi.fn();
11
11
  shotResult.event(g);
12
12
 
@@ -1,12 +1,12 @@
1
- import { late, shared } from "silentium";
2
- import { onlyChanged } from "../behaviors/OnlyChanged";
3
- import { shot } from "../behaviors/Shot";
1
+ import { Late, Shared } from "silentium";
2
+ import { OnlyChanged } from "../behaviors/OnlyChanged";
3
+ import { Shot } from "../behaviors/Shot";
4
4
  import { expect, test } from "vitest";
5
5
 
6
6
  test("Shot._onlyChanged.test", () => {
7
- const baseSrc = late<number>(123);
8
- const sharedBase = shared(baseSrc.event, true);
9
- const resultSrc = shot(sharedBase.event, onlyChanged(sharedBase.event));
7
+ const baseSrc = Late<number>(123);
8
+ const sharedBase = Shared(baseSrc.event, true);
9
+ const resultSrc = Shot(sharedBase.event, OnlyChanged(sharedBase.event));
10
10
 
11
11
  const vals: number[] = [];
12
12
 
@@ -1,21 +1,21 @@
1
- import { EventType, isFilled, primitive } from "silentium";
1
+ import { EventType, isFilled, Primitive } from "silentium";
2
2
 
3
3
  /**
4
- * Helps to represent only last fresh value of some source, refreshing controls by shotSrc
4
+ * Helps to represent only last fresh value Of some source, refreshing controls by shotSrc
5
5
  * https://silentium-lab.github.io/silentium-components/#/behaviors/shot
6
6
  */
7
- export const shot = <T>(
7
+ export function Shot<T>(
8
8
  targetSrc: EventType<T>,
9
9
  triggerSrc: EventType,
10
- ): EventType<T> => {
11
- return (u) => {
12
- const targetSync = primitive(targetSrc);
10
+ ): EventType<T> {
11
+ return (user) => {
12
+ const targetSync = Primitive(targetSrc);
13
13
 
14
14
  triggerSrc(() => {
15
15
  const value = targetSync.primitive();
16
16
  if (isFilled(value)) {
17
- u(value);
17
+ user(value);
18
18
  }
19
19
  });
20
20
  };
21
- };
21
+ }
@@ -1,12 +1,12 @@
1
- import { EventType, executorApplied } from "silentium";
1
+ import { EventType, ExecutorApplied } from "silentium";
2
2
 
3
- export const task = <T>(
3
+ export function Task<T>(
4
4
  baseSrc: EventType<T>,
5
5
  delay: number = 0,
6
- ): EventType<T> => {
7
- return (u) => {
6
+ ): EventType<T> {
7
+ return (user) => {
8
8
  let prevTimer: unknown | null = null;
9
- executorApplied(baseSrc, (fn) => {
9
+ ExecutorApplied(baseSrc, (fn) => {
10
10
  return (v) => {
11
11
  if (prevTimer) {
12
12
  clearTimeout(prevTimer as number);
@@ -15,6 +15,6 @@ export const task = <T>(
15
15
  fn(v);
16
16
  }, delay);
17
17
  };
18
- })(u);
18
+ })(user);
19
19
  };
20
- };
20
+ }
@@ -1,5 +1,5 @@
1
- import { any, late, shared } from "silentium";
2
- import { tick } from "../behaviors/Tick";
1
+ import { Any, Late, Shared } from "silentium";
2
+ import { Tick } from "../behaviors/Tick";
3
3
  import { afterEach, beforeEach, expect, test, vi } from "vitest";
4
4
 
5
5
  beforeEach(() => {
@@ -12,9 +12,9 @@ afterEach(() => {
12
12
  });
13
13
 
14
14
  test("Tick.test", async () => {
15
- const s1 = late<number>(1);
16
- const s2 = late<number>(2);
17
- const tickSrc = shared(tick(any(s1.event, s2.event)), true);
15
+ const s1 = Late<number>(1);
16
+ const s2 = Late<number>(2);
17
+ const tickSrc = Shared(Tick(Any(s1.event, s2.event)), true);
18
18
 
19
19
  const g = vi.fn();
20
20
  tickSrc.event(g);
@@ -1,11 +1,11 @@
1
1
  import { EventType } from "silentium";
2
2
 
3
3
  /**
4
- * Accumulates the last value of the source and returns one result once per tick
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
- export const tick = <T>(baseSrc: EventType<T>): EventType<T> => {
8
- return (u) => {
7
+ export function Tick<T>(baseSrc: EventType<T>): EventType<T> {
8
+ return (user) => {
9
9
  let microtaskScheduled = false;
10
10
  let lastValue: T | null = null;
11
11
 
@@ -14,7 +14,7 @@ export const tick = <T>(baseSrc: EventType<T>): EventType<T> => {
14
14
  queueMicrotask(() => {
15
15
  microtaskScheduled = false;
16
16
  if (lastValue !== null) {
17
- u(lastValue);
17
+ user(lastValue);
18
18
  lastValue = null;
19
19
  }
20
20
  });
@@ -27,4 +27,4 @@ export const tick = <T>(baseSrc: EventType<T>): EventType<T> => {
27
27
  }
28
28
  });
29
29
  };
30
- };
30
+ }
@@ -1,11 +1,11 @@
1
- import { late } from "silentium";
1
+ import { Late } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
- import { and } from "../boolean/And";
3
+ import { And } from "../boolean/And";
4
4
 
5
5
  test("And.test", () => {
6
- const one = late<boolean>(false);
7
- const two = late<boolean>(false);
8
- const result = and(one.event, two.event);
6
+ const one = Late<boolean>(false);
7
+ const two = Late<boolean>(false);
8
+ const result = And(one.event, two.event);
9
9
  const g = vi.fn();
10
10
  result(g);
11
11
  expect(g).toHaveBeenLastCalledWith(false);
@@ -1,18 +1,18 @@
1
- import { all, EventType } from "silentium";
1
+ import { All, EventType } from "silentium";
2
2
 
3
3
  /**
4
4
  * https://silentium-lab.github.io/silentium-components/#/boolean/and
5
5
  */
6
- export const and = (
6
+ export function And(
7
7
  oneSrc: EventType<boolean>,
8
8
  twoSrc: EventType<boolean>,
9
- ): EventType<boolean> => {
10
- return (u) => {
11
- all(
9
+ ): EventType<boolean> {
10
+ return (user) => {
11
+ All(
12
12
  oneSrc,
13
13
  twoSrc,
14
14
  )(([one, two]) => {
15
- u(one && two);
15
+ user(one && two);
16
16
  });
17
17
  };
18
- };
18
+ }
@@ -1,9 +1,9 @@
1
- import { of } from "silentium";
2
- import { bool } from "../boolean/Bool";
1
+ import { Of } from "silentium";
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))(o);
7
+ Bool(Of(1))(o);
8
8
  expect(o).toHaveBeenCalledWith(true);
9
9
  });
@@ -1,11 +1,11 @@
1
- import { applied, EventType } from "silentium";
1
+ import { Applied, EventType } from "silentium";
2
2
 
3
3
  /**
4
- * Convert any source to boolean source
4
+ * Convert Any source to boolean source
5
5
  * https://silentium-lab.github.io/silentium-components/#/boolean/bool
6
6
  */
7
- export const bool = (baseSrc: EventType): EventType<boolean> => {
8
- return (u) => {
9
- applied(baseSrc, Boolean)(u);
7
+ export function Bool(baseSrc: EventType): EventType<boolean> {
8
+ return (user) => {
9
+ Applied(baseSrc, Boolean)(user);
10
10
  };
11
- };
11
+ }