UNPKG

@mindsorg/web3modal-ts

Version:

Web3modal's provider layer abstraction for simple implementation of web3 wallet connections

38 lines 931 B
export let local; if (typeof window !== 'undefined' && typeof window.localStorage !== 'undefined') { local = window.localStorage; } export const setLocal = (key, data) => { const jsonData = JSON.stringify(data); if (local) { local.setItem(key, jsonData); } }; export const getLocal = (key) => { let data = null; let raw = null; if (local) { raw = local.getItem(key); } if (raw && typeof raw === 'string') { try { data = JSON.parse(raw); } catch (error) { return null; } } return data; }; export const removeLocal = (key) => { if (local) { local.removeItem(key); } }; export const updateLocal = (key, data) => { const localData = getLocal(key) || {}; const mergedData = Object.assign(Object.assign({}, localData), data); setLocal(key, mergedData); }; //# sourceMappingURL=local.js.map