Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

npm version Gitter Chat

Storage

Description

This utility offers a simple API for storing Javascript objects in HTML5 web storage using distinct namespaces


Requirements


Installation

Installation with Veams

veams install u storage
veams -i u storage

Usage (API)

Just initialize on demand like this:

let myStorage = new Storage({
	type: 'permanent', // or 'session'
	name: 'someName' // custom namespace (e.g. from module)
});

Constructor

Storage(opts: StorageOptions)

/**
 * 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
 */

Properties

  • length {Number} - item count

Methods

setItem(name:String, obj:Object)

/**
 * Set item
 *
 * @param {String} name - item name
 * @param {Object} obj - object to save
 */

getItem (name:String)

/**
 * Get item by name
 *
 * @param {String} name - item name
 * @return {Object} - object retrieved by item name
 */

getAllItems ()

/**
 * Get all items
 *
 * @public
 *
 * @return {Object} - object containing all items
 */

removeItem (name:String)

/**
 * Remove item by name
 *
 * @param {String} name - item name
 */

clear ()

/**
 * Clear all items
 */

About

Offers a simple API for storing Javascript objects in HTML5 web storage

Resources

Packages

No packages published