Some Code Cleanup

This commit is contained in:
2023-12-25 21:54:40 +01:00
parent a2687083e0
commit 3108d9bf20
61 changed files with 305 additions and 247 deletions

View File

@@ -33,7 +33,7 @@ export function cached<T>(normal: T, init: () => Promise<T>): Cached<T> {
init().then(data => {
store.set(data);
});
}
};
return {
...readonly(store),
@@ -52,7 +52,7 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
const stores: Map<T, Cached<K>> = new Map();
return (arg: T) => {
if(stores.has(arg)) {
return stores.get(arg)!!;
return stores.get(arg)!;
} else {
const store = writable<K>(normal);
let first = true;
@@ -61,7 +61,7 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
init(arg).then(data => {
store.set(data);
});
}
};
const cachedStore = {
...readonly(store),
@@ -78,5 +78,5 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
stores.set(arg, cachedStore);
return cachedStore;
}
}
};
}