Skip to content

A minimal localStorage wrapper that fallbacks to in-memory when localStorage is not available.

License

Notifications You must be signed in to change notification settings

publicclass/store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

store

A minimal local storage wrapper which stores in-memory in case localStorage is not available.

Example

var store = require('store')(); // defaults to prefix "publicclass/store/"
store.set('user', {name: 'bob', id: 1, friends: []}); // = object
store.get('user'); // = object

API

new Store([prefix])

Create a new Store instance.

Store#get(key)

Returns the value stored at that key (if any).

Store#set(key, value)

Store the value to the corresponding key. And returns the unmodified set value.

note: it stores as json so it won't accept any circular references in objects

Store#del(key)

Removes the stored key and returns true or false depending if it existed.

Store#length

The current number of keys stored in the instance.

About

A minimal localStorage wrapper that fallbacks to in-memory when localStorage is not available.

Resources

License

Stars

Watchers

Forks

Packages