MCPcopy Create free account
hub / github.com/Noumena-Network/code / createState

Function createState

src/session/applyLocalQueryEvent.test.ts:12–26  ·  view source on GitHub ↗
(initial: T)

Source from the content-addressed store, hash-verified

10type SetStateAction<T> = T | ((prev: T) => T)
11
12function createState<T>(initial: T): {
13 get: () => T
14 set: (action: SetStateAction<T>) => void
15} {
16 let value = initial
17 return {
18 get: () => value,
19 set: action => {
20 value =
21 typeof action === 'function'
22 ? (action as (prev: T) => T)(value)
23 : action
24 },
25 }
26}
27
28function createDeps(options?: {
29 messages?: unknown[]

Callers 2

createDepsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected