mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-11 20:27:12 +01:00
21 lines
469 B
JavaScript
21 lines
469 B
JavaScript
export function loadLocalStorageData (itemKey) {
|
|
try {
|
|
const serializedData = localStorage.getItem(itemKey)
|
|
if (serializedData === null) {
|
|
return undefined
|
|
}
|
|
return JSON.parse(serializedData)
|
|
} catch (err) {
|
|
return undefined
|
|
}
|
|
}
|
|
|
|
export function saveLocalStorageData (data, itemKey) {
|
|
try {
|
|
const serializedData = JSON.stringify(data)
|
|
localStorage.setItem(itemKey, serializedData)
|
|
} catch (err) {
|
|
console.warn(err)
|
|
}
|
|
}
|