n0mbers/src/storage.ts

13 lines
409 B
TypeScript

export function setItem(k: string, v: string): void {
return localStorage.setItem(k, v)
}
export function getItem(k: string): string | null
export function getItem(k: string, defaultValue: any): string
export function getItem(k: string, defaultValue?: any): string | null {
const val = localStorage.getItem(k)
if (defaultValue !== undefined && val === null) {
return defaultValue
}
return val
}