import IStorage , { IStorageSync } from 'common/abstractions/services/storage' ; const Storage = { getValue ( key ) { return window . localStorage . getItem ( key ) ; } , setValue ( key , value ) { window . localStorage . setItem ( key , value ) ; } , hasValue ( key ) { return window . localStorage . getItem ( key ) != null ; } , removeValue ( key ) { const hasValue = Storage . hasValue ( key ) ; if ( ! hasValue ) { return false ; } window . localStorage . removeItem ( key ) ; return true ; } , } ; export const StorageAsync = { getValue ( key ) { return Promise . resolve ( Storage . getValue ( key ) ) ; } , setValue ( key , value ) { Storage . setValue ( key , value ) ; return Promise . resolve ( ) ; } , hasValue ( key ) { return Promise . resolve ( Storage . hasValue ( key ) ) ; } , remove ( key ) { Storage . removeValue ( key ) ; return Promise . resolve ( ) ; } , } ; export class KeyStorage { constructor ( readonly key ) { } get value ( ) { return Storage . getValue ( this . key ) ; } set value ( v ) { Storage . setValue ( this . key , v ) ; } } export class KeyStorageConverted < T > { private readonly _storage : KeyStorage ; constructor ( key , readonly input , readonly output ) { this . _storage = new KeyStorage ( key ) ; } get value ( ) : T { return this . output ( this . _storage . value ) ; } set value ( v ) { this . _storage . value = this . input ( v ) ; } } export default Storage ;