browser-session-store
v2.0.2
Published
Async sessionStorage interface with a Node fallback
Downloads
4
Maintainers
Readme
browser-session-store
Async sessionStorage interface with a Node fallback
Install
$ npm install --save browser-session-store
Usage
var session = require('browser-session-store')
session.put('foo', 'bar', function (err) {
//=> err === null
session.get('foo', function (err, value) {
//=> err === null
//=> value === 'bar'
})
})
API
session.get(key, callback)
-> undefined
Get data from the store. Parses as JSON.
key
Required
Type: string
callback
Required
Type: function
Arguments: err, value
session.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
session.remove(key, [callback])
-> undefined
Remove an item.
key
Required
Type: string
callback
Required
Type: function
Arguments: err
session.clear([callback])
-> undefined
Clear the store.
callback
Required
Type: function
Arguments: err
Related
- browser-async-store: the engine for browser-session-store
- browser-store: an API compatible alternative that uses
localStorage
when available
License
MIT © Ben Drucker