This utility offers a simple API for storing Javascript objects in HTML5 web storage using distinct namespaces
- @veams/helpers - Object extend helper.
veams install u storage
veams -i u storage
Just initialize on demand like this:
let myStorage = new Storage({
type: 'permanent', // or 'session'
name: 'someName' // custom namespace (e.g. from module)
});
/**
* Constructor
*
* @param {Object} opts - options which will be passed as object
* @param {String} opts.type - storage type ('permanent' || 'session')
* @param {String} opts.name - namespace in which items will be saved
*/
- length {
Number
} - item count
/**
* Set item
*
* @param {String} name - item name
* @param {Object} obj - object to save
*/
/**
* Get item by name
*
* @param {String} name - item name
* @return {Object} - object retrieved by item name
*/
/**
* Get all items
*
* @public
*
* @return {Object} - object containing all items
*/
/**
* Remove item by name
*
* @param {String} name - item name
*/
/**
* Clear all items
*/