UNPKG

@svelte-on-solana/wallet-adapter-core

Version:

The core of the wallet adapter is a Svelte Store which exposes methods and properties to run the wallet in your application. This allows to share this data among all components in your application.

27 lines (24 loc) 716 B
export function getLocalStorage<T>(key: string, defaultValue: T | null = null): T | null { try { const value = localStorage.getItem(key); if (value) return JSON.parse(value) as T; } catch (error) { if (typeof window !== 'undefined') { console.error(error); } } return defaultValue; } export function setLocalStorage<T>(key: string, value: T | null = null): void { try { if (value === null) { localStorage.removeItem(key); } else { localStorage.setItem(key, JSON.stringify(value)); } } catch (error) { if (typeof window !== 'undefined') { console.error(error); } } }