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/CHANGELOG.md +8 -0
- package/dist/silentium-components.cjs +104 -4
- package/dist/silentium-components.cjs.map +1 -1
- package/dist/silentium-components.d.ts +38 -1
- package/dist/silentium-components.js +101 -5
- package/dist/silentium-components.js.map +1 -1
- package/dist/silentium-components.min.js +1 -1
- package/dist/silentium-components.min.mjs +1 -1
- package/dist/silentium-components.min.mjs.map +1 -1
- package/dist/silentium-components.mjs +101 -5
- package/dist/silentium-components.mjs.map +1 -1
- package/docs/assets/css/base.css +15 -0
- package/docs/pages/behaviors/dirty.html +48 -1
- package/docs/pages/behaviors/loading.html +43 -0
- package/docs/pages/index.html +5 -0
- package/docs/pages/structures/hash-table.html +49 -0
- package/docs/pages/structures.html +7 -0
- package/docs/routes.json +1 -1
- package/package.json +1 -1
- package/src/behaviors/Loading.ts +3 -0
- package/src/behaviors/Touched.ts +1 -0
- package/src/behaviors/index.ts +3 -0
- package/src/index.ts +2 -0
- package/src/structures/HashTable.test.ts +15 -0
- package/src/structures/HashTable.ts +31 -0
- package/src/structures/index.ts +1 -0
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
package/src/behaviors/Loading.ts
CHANGED
package/src/behaviors/Touched.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class Touched {}
|
package/src/index.ts
CHANGED
|
@@ -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";
|