2.0.2 • Published 9 years ago

browser-store v2.0.2

Weekly downloads
12
License
MIT
Repository
github
Last release
9 years ago

browser-store Build Status

Async browser storage with Node fallback

Uses local storage, then session storage, then an in-memory store if neither are available.

Install

$ npm install --save browser-store

Usage

var store = require('browser-store')

store.put('foo', 'bar', function (err) {
  //=> err === null
  store.get('foo', function (err, value) {
    //=> err === null
    //=> value === 'bar'  
  })
})

API

store.get(key, callback) -> undefined

Get data from the store. Parses as JSON.

key

Required
Type: string

callback

Required
Type: function
Arguments: err, value

store.put(key, value, [callback]) -> undefined

Add an item to the store (or overwrite an existing item). Data will be stringified as JSON.

key

Required
Type: string

value

Required
Type: any

callback

Required
Type: function
Arguments: err

store.remove(key, [callback]) -> undefined

Remove an item.

key

Required
Type: string

callback

Required
Type: function
Arguments: err

store.clear([callback]) -> undefined

Clear the store.

callback

Required
Type: function
Arguments: err

Related

License

MIT © Ben Drucker