14 lines
383 B
TypeScript
14 lines
383 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 {
|
||
|
try {
|
||
|
return localStorage.getItem(k) ?? null
|
||
|
}
|
||
|
catch (e) {
|
||
|
return defaultValue ?? null
|
||
|
}
|
||
|
}
|