jwallet-web-storage

0.2.3 • Public • Published

jwallet-web-storage

Web Storage (API) polyfill. Using following storages in order of priority: localStorage -> cookie -> memory

Get Started

npm install jwallet-web-storage
const storage = require('jwallet-web-storage')

API

The (Web Storage API)[https://html.spec.whatwg.org/multipage/webstorage.html] provides mechanisms by which browsers can store key/value pairs.

setItem(key, value)

Adds key to the storage, or updates that key's value if it already exists.

Examples

storage.setItem('Key', 'Value')
 
const objectStorageValue = { foo: 'bar' }
storage.setItem('AnotherKey', JSON.stringify(objectStorageValue))

getItem(key)

Returns that key's value.

Examples

storage.getItem('Key') //> Value
 
JSON.parse(storage.getItem('AnotherKey')) //> { foo: 'bar' }

removeItem(key)

Removes key from the storage.

storage.removeItem('Key')
storage.removeItem('AnotherKey')

Package Sidebar

Install

npm i jwallet-web-storage

Weekly Downloads

3

Version

0.2.3

License

MIT

Unpacked Size

11.3 kB

Total Files

16

Last publish

Collaborators

  • violentoff