import createInMemoryStorage from "./InMemoryStorage" ; export interface PromisifiedStorage < T = string > { length : Promise < number > ; clear ( ) : Promise < void > ; key ( n ) : Promise < T | null > ; /**
     * value = storage[key]
     */ getItem ( key ) : Promise < T | null > ; /**
     * delete storage[key]
     */ removeItem ( key ) : Promise < void > ; /**
     * storage[key] = value
     */ setItem ( key , value ) : Promise < void > ; } /**
 * BackedPromisifedStorage.
 */ class BackedPromisifedStorage implements PromisifiedStorage { private storage : Storage ; constructor ( storage ) { this . storage = storage ; } public get length ( ) { return Promise . resolve ( this . storage . length ) ; } public clear ( ) { return Promise . resolve ( this . storage . clear ( ) ) ; } public key ( n ) { return Promise . resolve ( this . storage . key ( n ) ) ; } public getItem ( key ) { return Promise . resolve ( this . storage . getItem ( key ) ) ; } public setItem ( key , value ) { return Promise . resolve ( this . storage . setItem ( key , value ) ) ; } public removeItem ( key ) { return Promise . resolve ( this . storage . removeItem ( key ) ) ; } } export default function createPromisifiedStorage ( storage = createInMemoryStorage ( ) ) { return new BackedPromisifedStorage ( storage ) ; }