(
name: string,
init: T,
)
| 2 | import {createStore, produce, type SetStoreFunction, type Store, unwrap} from 'solid-js/store' |
| 3 | |
| 4 | export function createLocalStore<T extends object>( |
| 5 | name: string, |
| 6 | init: T, |
| 7 | ): [Store<T>, SetStoreFunction<T>] { |
| 8 | const localState = localStorage.getItem(name) |
| 9 | // const localState = undefined |
| 10 | const [state, setState] = createStore<T>( |
| 11 | localState ? JSON.parse(localState) as any : init, {name} |
| 12 | ) |
| 13 | s.createEffect(() => localStorage.setItem(name, JSON.stringify(state))) |
| 14 | return [state, setState] |
| 15 | } |
| 16 | |
| 17 | export function removeIndex<T>(array: readonly T[], index: number): T[] { |
| 18 | return [...array.slice(0, index), ...array.slice(index + 1)] |
no outgoing calls
no test coverage detected
searching dependent graphs…