MCPcopy
hub / github.com/pmndrs/zustand / createPersistentStore

Function createPersistentStore

tests/persistSync.test.tsx:8–33  ·  view source on GitHub ↗
(initialValue: string | null)

Source from the content-addressed store, hash-verified

6import { replacer, reviver } from './test-utils'
7
8const createPersistentStore = (initialValue: string | null) => {
9 let state = initialValue
10
11 const getItem = (): string | null => {
12 getItemSpy()
13 return state
14 }
15 const setItem = (name: string, newState: string) => {
16 setItemSpy(name, newState)
17 state = newState
18 }
19 const removeItem = (name: string) => {
20 removeItemSpy(name)
21 state = null
22 }
23
24 const getItemSpy = vi.fn()
25 const setItemSpy = vi.fn()
26 const removeItemSpy = vi.fn()
27
28 return {
29 storage: { getItem, setItem, removeItem },
30 getItemSpy,
31 setItemSpy,
32 }
33}
34
35describe('persist middleware with sync configuration', () => {
36 const consoleError = console.error

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…