mirror of
https://github.com/koel/koel
synced 2024-12-30 06:23:05 +00:00
17 lines
432 B
TypeScript
17 lines
432 B
TypeScript
import { get as baseGet, set as baseSet, remove as baseRemove } from 'local-storage'
|
|
|
|
export const localStorageService = {
|
|
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)
|
|
}
|
|
}
|