--------- Co-authored-by: gguio <nikvish150@gmail.com> Co-authored-by: Vitaly <vital2580@icloud.com>
13 lines
457 B
TypeScript
13 lines
457 B
TypeScript
import { CustomCommand } from './KeybindingsCustom'
|
|
|
|
type StorageData = {
|
|
customCommands: Record<string, CustomCommand>
|
|
// ...
|
|
}
|
|
|
|
export const getStoredValue = <T extends keyof StorageData> (name: T): StorageData[T] | undefined => {
|
|
return localStorage[name] ? JSON.parse(localStorage[name]) : undefined
|
|
}
|
|
export const setStoredValue = <T extends keyof StorageData> (name: T, value: StorageData[T]) => {
|
|
localStorage[name] = JSON.stringify(value)
|
|
}
|