mock-storage

In-memory Storage API

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
mock-storage
1.1.07 years ago7 years agoMinified + gzip package size for mock-storage in KB

Readme

Storage Mock
In memory representation of Storage Interface

100% compliant to TypeScript's Storage interface. This library makes use of ES2015 Proxy and Map, polyfills may be required.

Get it

yarn add --dev mock-storage
# or
npm install --save-dev mock-storage

API and Usage

mockStorage(map?: Map<string, string>): Storage

Creates an in-memory version of LocalStorage, optionally with starting data.
import { mockStorage } from 'mock-storage'

const storage = mockStorage()

// set item
storage.setItem('foo', 'bar')
// get item
console.log(storage.getItem('foo')) // -> bar

// Using property access
storage.foo = 'baz'
console.log(storage.foo) // -> baz