File

src/MemoryStorage.ts

Implements

ICustomStorage

Index

Methods
Accessors

Methods

Public clear
clear()
Returns : void
Public getItem
getItem(key: string)
Parameters :
Name Type Optional Description
key string
Returns : any
Public hasItem
hasItem(key: string)
Parameters :
Name Type Optional Description
key string
Returns : any
Public key
key(index: number)
Parameters :
Name Type Optional Description
index number
Returns : any
Public removeItem
removeItem(key: string)
Parameters :
Name Type Optional Description
key string
Returns : void
Public setItem
setItem(key: string, value: string)
Parameters :
Name Type Optional Description
key string
value string
Returns : void

Accessors

length
getlength()
import {ICustomStorage} from './metadata'

// This is dumb TODO: REMOVE
declare const Map: any

const _cache = new Map()

const getKeys = (): any[] => Array.from(_cache.keys())

export class MemoryStorage implements ICustomStorage {
  public hasItem(key: string) {
    return _cache.has(key)
  }

  public getItem(key: string) {
    return _cache.get(key)
  }

  public setItem(key: string, value: string) {
    _cache.set(key, value)
  }

  public removeItem(key: string) {
    _cache.delete(key)
  }

  public clear() {
    _cache.clear()
  }

  public key(index: number) {
    return getKeys()[index]
  }

  public get length() {
    return getKeys().length
  }
}

results matching ""

    No results matching ""