Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

generic_store

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generic_store

Provides an implementation of store.js in memory for testing + a wrapper around store.js for avoiding conflicts

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

generic_store.js

Build Status NPM version Bower version Project status license status Total views Gittip

STILL IN PROGRESS - MISSING FEATURES - API MAY CHANGE

Introduction

generic_store.js wraps store.js and add :

  • an implementation in memory for safe tests or other use
  • an (optional) automatic key prefixing for avoiding conflicts (NOT IMPLEMENTED)

NOTE : ONLY set() AND get() ARE IMPLEMENTED FOR NOW !

License : public domain (http://unlicense.org/)

User Story

In you web app, you use the convenient local storage instead of fat cookies. Of course, you use store.js (https://github.com/marcuswestin/store.js) to access the local storage.

Now there are two problems :

  • it's unsafe to unit test your app since local storage is persistent and shared
  • you may mess with another local storage user which use the same keys

Solution :

  • Have a store.js implementation in memory for tests
  • Have an automatic prefixing of keys

Usage

define(
[
	'generic_store/generic_store',
],
function(GenericStore) {
	"use strict";

	// new store, in memory, guaranteed to be empty
	var store1 = GenericStore.make_new("memory");
	// new store, in memory, guaranteed to be empty, different from the previous one
	var store2 = GenericStore.make_new("memory");
	// existing store (local storage), "existing" reminds us that it may already contain data
	var store3 = GenericStore.get_existing("local");

	// now use your store like store.js
	store.set('username', 'marcus');
	store.get('username');
	store.set('user', { name: 'marcus', likes: 'javascript' });

Installation

Bower : bower install generic_store.js Npm : npm install generic_store

Unit tests

in the 'spec' folder. See also readme.txt in the 'test_runner' folder.

Keywords

FAQs

Package last updated on 04 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc