MCPcopy
hub / github.com/simstudioai/sim / setItem

Method setItem

apps/sim/lib/core/utils/browser-storage.ts:49–62  ·  view source on GitHub ↗

* Safely sets an item in localStorage * @param key - The storage key * @param value - The value to store * @returns True if successful, false otherwise

(key: string, value: T)

Source from the content-addressed store, hash-verified

47 * @returns True if successful, false otherwise
48 */
49 static setItem<T>(key: string, value: T): boolean {
50 if (typeof window === 'undefined') {
51 return false
52 }
53
54 try {
55 const serializedValue = typeof value === 'string' ? value : JSON.stringify(value)
56 window.localStorage.setItem(key, serializedValue)
57 return true
58 } catch (error) {
59 logger.warn(`Failed to set localStorage item "${key}":`, error)
60 return false
61 }
62 }
63
64 /**
65 * Safely removes an item from localStorage

Callers 15

store.tsFile · 0.80
saveExecutionPointerFunction · 0.80
store.tsFile · 0.80
writeOAuthReturnContextFunction · 0.80
syncThemeToNextThemesFunction · 0.80
isAvailableMethod · 0.80
touchMethod · 0.80
removeMethod · 0.80
pruneMethod · 0.80
storeMethod · 0.80

Calls 1

warnMethod · 0.65

Tested by

no test coverage detected