@streammedev/storage

1.0.0 • Public • Published

A Web Storage Wrapper

NPM Version NPM Downloads js-happiness-style

Web storage for cookies/localStorage/sessionStorage/memory with expiration and other helpful features.

Features:

  • Multiple storage drivers guarantee at minimum in memory storage
  • Filter value, useful for storing json or other non-string data
  • Filter key, useful for consolidating keys
  • Use cookie like path and expires with local and session storage

Install

$ npm install --save @streammedev/storage

Usage

var Storage = require('@streammedev/storage');

var store = new Storage({
	// backend: null, specify a backend with either a 
	// string name or constructor function
	backend: 'memory'

	// Sets the domain, only used with cookies
	domain: 'example.com',

	// Filter function for getting and settting
	setValueFilter: identity,
	getValueFilter: identity,

	// Filter function for the key
	keyFilter: identity
});

store.setItem('foo', 'bar');
store.getItem('foo'); // 'bar'
store.removeItem('foo');
store.getItem('foo'); // undefined
store.clear('foo'); // undefined

Contributing

Contributions are welcome. Please see our guidelines in CONTRIBUTING.md.

Package Sidebar

Install

npm i @streammedev/storage

Weekly Downloads

2

Version

1.0.0

License

ISC

Last publish

Collaborators

  • streammedev
  • wesleytodd