mock-storage
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i mock-storage

Weekly Downloads

123

Version

1.1.0

License

MIT

Last publish

Collaborators

  • tylors