svas 0.1.7 → 0.1.9
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/dist/collection.d.ts +2 -2
- package/dist/ensure.d.ts +1 -1
- package/dist/value.d.ts +1 -0
- package/dist/value.js +5 -4
- package/package.json +4 -3
package/dist/collection.d.ts
CHANGED
|
@@ -35,9 +35,9 @@ interface Options<T = unknown, E extends Error = Error> {
|
|
|
35
35
|
map?: (item: any) => T;
|
|
36
36
|
/** Sorting function applied on updates. */
|
|
37
37
|
sort?: (a: T, b: T) => number;
|
|
38
|
-
/** Time in milliseconds before revalidating the collection. */
|
|
38
|
+
/** Time in milliseconds before revalidating the collection. Defaults to 300 seconds. */
|
|
39
39
|
revalidate?: number;
|
|
40
|
-
/** Whether to keep the collection while revalidating. */
|
|
40
|
+
/** Whether to keep the collection while revalidating. Defaults to false. */
|
|
41
41
|
stale?: boolean;
|
|
42
42
|
/** Values store. */
|
|
43
43
|
values?: Values<T, E>;
|
package/dist/ensure.d.ts
CHANGED
package/dist/value.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ type Input<T, M, Default> = M extends (arg: infer P) => T ? P : Default;
|
|
|
3
3
|
declare class Value<T> implements Writable<T | null> {
|
|
4
4
|
private readonly store;
|
|
5
5
|
private readonly map?;
|
|
6
|
+
private readonly default;
|
|
6
7
|
constructor(options: Options<T>);
|
|
7
8
|
set<I = T>(value: Input<T, typeof this.map, I> | null): void;
|
|
8
9
|
update(updater: Updater<T | null>): void;
|
package/dist/value.js
CHANGED
|
@@ -3,12 +3,13 @@ import { browser } from '$app/environment';
|
|
|
3
3
|
class Value {
|
|
4
4
|
store;
|
|
5
5
|
map;
|
|
6
|
+
default;
|
|
6
7
|
constructor(options) {
|
|
7
8
|
const persist = browser && options.persist !== undefined;
|
|
8
|
-
|
|
9
|
+
this.default = options.default ?? null;
|
|
9
10
|
this.store = persist
|
|
10
|
-
? persistent(options.persist,
|
|
11
|
-
: writable(
|
|
11
|
+
? persistent(options.persist, this.default, options.session)
|
|
12
|
+
: writable(this.default);
|
|
12
13
|
if (browser) {
|
|
13
14
|
if (options.bind)
|
|
14
15
|
this.bind(options.bind);
|
|
@@ -39,7 +40,7 @@ class Value {
|
|
|
39
40
|
bind(store) {
|
|
40
41
|
store.subscribe((value) => {
|
|
41
42
|
if (value === null)
|
|
42
|
-
this.store.set(
|
|
43
|
+
this.store.set(this.default);
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svas",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build && npm run prepack",
|
|
@@ -30,10 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@lucide/svelte": "*",
|
|
33
|
-
"svelte": "^5.0.0"
|
|
33
|
+
"svelte": "^5.0.0",
|
|
34
|
+
"@sveltejs/kit": "*"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@eslint/compat": "^1.2.
|
|
37
|
+
"@eslint/compat": "^1.2.9",
|
|
37
38
|
"@eslint/js": "^9.18.0",
|
|
38
39
|
"@sveltejs/adapter-auto": "^6.0.0",
|
|
39
40
|
"@sveltejs/kit": "^2.16.0",
|