Superstore is a simple lightweight asynchronous wrapper around the Web Storage APIs localStorage and sessionStorage. Its features include:
If you require an synchronous version please use superstore-sync instead.
- It is resilient to iOS's strange behaviour in private browsing mode.
- It accepts objects as values and runs
JSON.stringify
on #set andJSON.parse
on #get for you.
npm install superstore --save
bower superstore --save
Superstore is an instantiable module. All Superstore methods return a Promise which will resolve with the stored value. Its methods are:
var localStore = new Superstore('local', 'foo');
var sessionStore = new Superstore('session', 'bar');
returns a boolean set to true if data is being persisted to storage, or false if it is being kept in memory (e.g. if localStorage is full or inaccessible).
var Superstore = require('superstore');
var store = new Superstore('local', 'foo');
store.get('bar').then(function(value){
// Do something with value
});