/**
 * InMemoryStorage is a dumb implementation of the Storage interface that will
 * not persist the data at all. It implements the Storage interface found:
 *
 * https://developer.mozilla.org/en-US/docs/Web/API/Storage
 */ export class InMemoryStorage < T = any > { private data : Record < string , T > ; constructor ( data = { } ) { this . data = data ; } public get length ( ) { return Object . keys ( this . data ) . length ; } public clear ( ) { this . data = { } ; } public key ( n ) { if ( this . length <= n ) { return null ; } return Object . keys ( this . data ) [ n ] ; } public getItem ( key ) { return this . data [ key ] || null ; } public setItem ( key , value ) { this . data [ key ] = value ; } public removeItem ( key ) { delete this . data [ key ] ; } public toString ( ) { return JSON . stringify ( this . data ) ; } } export default function createInMemoryStorage < T = any > ( data ? ) { return new InMemoryStorage < T > ( data ) ; }