single-storage
Browser storage that can only be read once
Install
$ npm install --save single-storage
Usage
var Storage = var storage = Storage auth: 'local' session: 'session' // auth will be read from localStorage// session will be read from sessionStorage //=> throws: storage can only be read once storageauth//=> writes new auth data to localStorage
API
Storage(keys)
-> function
Returns the read
function with set methods under each key.
keys
Required
Type: object
An object where the keys are storage keys and the values are either local
or session
. Each key can be written via ${key}.set(value)
.
read(callback)
-> undefined
Reads in all the values for the specified keys
.
callback
Required
Type: function
Arguments: err, data
Passes the storage data (key/value) to the supplied callback..
License
MIT © Ben Drucker