MCPcopy
hub / github.com/portainer/portainer / get

Function get

app/react/hooks/useLocalStorage.ts:27–42  ·  view source on GitHub ↗
(
  key: string,
  defaultValue: T,
  storage = localStorage
)

Source from the content-addressed store, hash-verified

25}
26
27export function get<T>(
28 key: string,
29 defaultValue: T,
30 storage = localStorage
31): T {
32 const value = storage.getItem(keyBuilder(key));
33 if (!value) {
34 return defaultValue;
35 }
36
37 try {
38 return JSON.parse(value);
39 } catch (e) {
40 return defaultValue;
41 }
42}
43
44export function set<T>(key: string, value: T, storage = localStorage) {
45 storage.setItem(keyBuilder(key), JSON.stringify(value));

Callers 4

useLocalStorageFunction · 0.70
insights-store.tsFile · 0.50
setNameFunction · 0.50
getUpdateFunction · 0.50

Calls 1

keyBuilderFunction · 0.70

Tested by

no test coverage detected