silentium-components 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/routes.json CHANGED
@@ -1 +1 @@
1
- ["pages/404.html","pages/index.html","pages/behaviors.html","pages/navigation.html","pages/navigation/navigation.html","pages/navigation/router.html","pages/behaviors/loading.html","pages/behaviors/dirty.html\n"]
1
+ ["pages/404.html","pages/index.html","pages/behaviors.html","pages/structures/hash-table.html","pages/structures.html","pages/navigation.html","pages/navigation/navigation.html","pages/navigation/router.html","pages/behaviors/loading.html","pages/behaviors/dirty.html\n"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "silentium-components",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/silentium-components.js",
@@ -7,6 +7,9 @@ import {
7
7
  value,
8
8
  } from "silentium";
9
9
 
10
+ /**
11
+ * https://silentium-lab.github.io/silentium-components/#/behaviors/loading
12
+ */
10
13
  export class Loading implements SourceObjectType<boolean> {
11
14
  private loadingSource = new SourceWithPool<boolean>();
12
15
 
@@ -0,0 +1 @@
1
+ export class Touched {}
@@ -0,0 +1,3 @@
1
+ export * from "./Dirty";
2
+ export * from "./Loading";
3
+ export * from "./Touched";
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from "./navigation";
2
2
  export * from "./controls";
3
3
  export * from "./page";
4
+ export * from "./behaviors";
5
+ export * from "./structures";
@@ -0,0 +1,15 @@
1
+ import { SourceSync, SourceWithPool } from "silentium";
2
+ import { HashTable } from "../structures/HashTable";
3
+ import { expect, test } from "vitest";
4
+
5
+ test("HashTable.test", () => {
6
+ const entrySource = new SourceWithPool<[string, string]>();
7
+ const hashTable = new SourceSync(new HashTable(entrySource));
8
+ entrySource.give(["key-one", "value-one"]);
9
+ entrySource.give(["key-two", "value-two"]);
10
+
11
+ expect(hashTable.syncValue()).toStrictEqual({
12
+ "key-one": "value-one",
13
+ "key-two": "value-two",
14
+ });
15
+ });
@@ -0,0 +1,31 @@
1
+ import {
2
+ GuestType,
3
+ Patron,
4
+ SourceObjectType,
5
+ SourceType,
6
+ SourceWithPool,
7
+ value,
8
+ } from "silentium";
9
+
10
+ /**
11
+ * https://silentium-lab.github.io/silentium-components/#/structures/hash-table
12
+ */
13
+ export class HashTable implements SourceObjectType<Record<string, unknown>> {
14
+ private source = new SourceWithPool<Record<string, unknown>>({});
15
+
16
+ public constructor(baseSource: SourceType<[string, unknown]>) {
17
+ value(
18
+ baseSource,
19
+ new Patron(([key, value]) => {
20
+ this.source.value((lastRecord) => {
21
+ lastRecord[key] = value;
22
+ });
23
+ }),
24
+ );
25
+ }
26
+
27
+ public value(guest: GuestType<Record<string, unknown>>) {
28
+ value(this.source, guest);
29
+ return this;
30
+ }
31
+ }
@@ -0,0 +1 @@
1
+ export * from "./HashTable";