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

Function normalizeWindowState

apps/desktop/src/main/vault.ts:304–330  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

302}
303
304function normalizeWindowState(value: unknown): PersistedWindowState | null {
305 if (!value || typeof value !== 'object') return null
306 const candidate = value as Record<string, unknown>
307 const x = candidate['x']
308 const y = candidate['y']
309 const width = candidate['width']
310 const height = candidate['height']
311 if (
312 typeof x !== 'number' ||
313 typeof y !== 'number' ||
314 typeof width !== 'number' ||
315 typeof height !== 'number' ||
316 !Number.isFinite(x) ||
317 !Number.isFinite(y) ||
318 !Number.isFinite(width) ||
319 !Number.isFinite(height)
320 ) {
321 return null
322 }
323 return {
324 x,
325 y,
326 width,
327 height,
328 isMaximized: Boolean(candidate['isMaximized'])
329 }
330}
331
332function normalizePersistedConfig(value: unknown): PersistedConfig {
333 if (!value || typeof value !== 'object') return { ...DEFAULT_CONFIG }

Callers 1

normalizePersistedConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected