packageDocumentation module import { UiStateStorage , UiStateStorageResult , UiStateStorageStatus } from "./UiStateStorage" ; public export class LocalStateStorage implements UiStateStorage { constructor ( public w = window ) { } public async getSetting ( settingNamespace , settingName ) { const setting = this . w . localStorage . getItem ( `${ settingNamespace }.${ settingName }` ) ; if ( setting !== null ) return { status : UiStateStorageStatus . Success , setting : JSON . parse ( setting ) } ; else return { status : UiStateStorageStatus . NotFound } ; } public async saveSetting ( settingNamespace , settingName , setting ) { this . w . localStorage . setItem ( `${ settingNamespace }.${ settingName }` , JSON . stringify ( setting ) ) ; return { status : UiStateStorageStatus . Success } ; } public async hasSetting ( settingNamespace , settingName ) { const name = `${ settingNamespace }.${ settingName }` ; const setting = this . w . localStorage . getItem ( name ) ; if ( setting === null ) return false ; return true ; } public async deleteSetting ( settingNamespace , settingName ) { const name = `${ settingNamespace }.${ settingName }` ; const setting = this . w . localStorage . getItem ( name ) ; if ( setting === null ) return { status : UiStateStorageStatus . NotFound } ; this . w . localStorage . removeItem ( name ) ; return { status : UiStateStorageStatus . Success } ; } }