stor
Figure out the best option for storing things in the browser and do it.
Example
// @todo: add a not ridiculous example
var stor = require('stor/stor.set('actor', {username: 'yolo17'}, function(err){
stor.get('actor', function(err, actor){
console.log(actor);
});
});
Docs
key
, fn
)
stor.get(key
, value
, fn
)
stor.set(key
, fn
)
stor.remove(n
, fn
)
stor.key(Backwards compat for localStorage.key
. Get the key value in the store at
position n
.
fn
)
stor.length(fn
)
stor.clear(name
)
stor.use(Manually switch to a different backend
name
).adapter(adapter
, ns
)
stor.use(Get an adapter for your framework of choice.
Adapters
Backbone
var Backbone = ;var sessionStorage = ;var historyBackend = sessionStorage;var History = BackboneCollection;
Todo
- proper api for applying partial updates like Backbone's patch method.
- id generation
- namespace support in all stores translated where needed (eg localstorage -> use prefix, indexeddb -> use table name)
License
MIT