import { Injectable } from '@angular/core' ; import { MemoryStorage } from '../interfaces/memory-storage.interface' ; @ Injectable ( ) export class BaseMemoryStorage implements MemoryStorage { /**
     * Storage data
     */ private data : { [ key ] : string ; } = { } ; get length ( ) : number { return Object . keys ( this . data ) . length ; } clear ( ) { this . data = { } ; } getItem ( key ) { return key in this . data ? this . data [ key ] : null ; } key ( index ) { const keys = Object . keys ( this . data ) ; return index >= 0 && keys . length < index ? keys [ index ] : null ; } removeItem ( key ) { delete this . data [ key ] ; } setItem ( key , value ) { this . data [ key ] = value ; } }