deno.land / x / solid_signals@solid-signals@1.3.7 / src / utils / signalMap.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { Signal } from "solid-js";
type DeepIndex<Map, Index extends number> = { [Key in keyof Map]: Map[Key] extends any[] ? Map[Key][Index] : DeepIndex<Map[Key], Index>;};
type RecursiveObject<T> = { [key: string | number | symbol]: T | RecursiveObject<T>;};
export function signalMap<Map extends RecursiveObject<Signal<{}>>>( map: Map): [DeepIndex<Map, 0>, DeepIndex<Map, 1>] { const state: any = {}; const setState: any = {};
for (const [key, value] of Object.entries(map)) [state[key], setState[key]] = value instanceof Array ? value : signalMap(value);
return [state, setState];}
solid_signals

Version Info

Tagged at
a year ago