1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00
metamask-extension/ui/lib/local-storage-helpers.js

21 lines
481 B
JavaScript
Raw Normal View History

2020-11-03 00:41:28 +01:00
export function loadLocalStorageData(itemKey) {
try {
const serializedData = window.localStorage.getItem(itemKey)
if (serializedData === null) {
return undefined
}
return JSON.parse(serializedData)
} catch (err) {
return undefined
}
}
2020-11-03 00:41:28 +01:00
export function saveLocalStorageData(data, itemKey) {
try {
const serializedData = JSON.stringify(data)
window.localStorage.setItem(itemKey, serializedData)
} catch (err) {
console.warn(err)
}
}