koel/resources/assets/js/services/ls.ts

18 lines
415 B
TypeScript
Raw Normal View History

2022-04-15 14:24:30 +00:00
import { get as baseGet, set as baseSet, remove as baseRemove } from 'local-storage'
export const ls = {
get: <T>(key: string, defaultValue: T | null = null): T | null => {
const value = baseGet<T>(key)
return value === null ? defaultValue : value
},
set: <T>(key: string, value: T): boolean => {
return baseSet<T>(key, value)
},
remove: (key: string): void => {
baseRemove(key)
}
}