MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / readFoldMap

Function readFoldMap

packages/app-core/src/lib/code-block-copy.ts:178–194  ·  view source on GitHub ↗
(storageKey: string)

Source from the content-addressed store, hash-verified

176}
177
178function readFoldMap(storageKey: string): Record<string, boolean> {
179 if (typeof window === 'undefined') return {}
180 try {
181 const raw = window.localStorage.getItem(storageKey)
182 if (!raw) return {}
183 const parsed = JSON.parse(raw)
184 if (!parsed || typeof parsed !== 'object') return {}
185 return Object.fromEntries(
186 Object.entries(parsed as Record<string, unknown>).filter(
187 (entry): entry is [string, boolean] =>
188 /^\d+$/.test(entry[0]) && typeof entry[1] === 'boolean'
189 )
190 )
191 } catch {
192 return {}
193 }
194}
195
196function codeBlockFoldStorageKey(notePath: string): string {
197 return `${CODE_BLOCK_FOLDS_STORAGE_PREFIX}:${encodeURIComponent(notePath)}`

Callers 2

readPersistedFoldStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected