Socket
Socket
Sign inDemoInstall

superstore-sync

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superstore-sync - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

bower.json

27

lib/superstore-sync.js

@@ -8,3 +8,5 @@ /**

var escapeRegex = require('escape-regexp-component');
var escapeRegex = function(str){
return String(str).replace(/([.*+?=^!:${}()|[\]\/\\])/g, '\\$1');
};

@@ -23,2 +25,6 @@ var keys = {};

function Superstore(type) {
this.storage = window[type];
}
/**

@@ -31,3 +37,3 @@ * get localstorage value for key falling back to in memory for iOS private browsing bug

*/
exports.get = function(key) {
Superstore.prototype.get = function(key) {
if (arguments.length !== 1) {

@@ -39,3 +45,3 @@ throw Error("get expects 1 argument, " + arguments.length + " given; " + key);

try {
data = localStorage[key];
data = this.storage[key];
} catch(e) {

@@ -62,3 +68,3 @@ persist = false; // Safari 8 with Cookies set to 'Never' throws on every read

*/
exports.set = function(key, value) {
Superstore.prototype.set = function(key, value) {
if (arguments.length !== 2) {

@@ -69,3 +75,3 @@ throw Error("set expects 2 arguments, " + arguments.length + " given; " + key);

try {
localStorage[key] = JSON.stringify(value);
this.storage[key] = JSON.stringify(value);
} catch(err) {

@@ -92,6 +98,6 @@

*/
exports.unset = function(key) {
Superstore.prototype.unset = function(key) {
delete store[key];
delete keys[key];
localStorage.removeItem(key);
this.storage.removeItem(key);
};

@@ -105,6 +111,6 @@

*/
exports.clear = function(clearPrefix) {
Superstore.prototype.clear = function(clearPrefix) {
if (!clearPrefix) {
if (persist) {
localStorage.clear();
this.storage.clear();
}

@@ -124,1 +130,4 @@ store = {};

};
module.exports.local = new Superstore('localStorage');
module.exports.session = new Superstore('sessionStorage');
{
"name": "superstore-sync",
"version": "1.1.0",
"version": "2.0.0",
"description": "Local storage, without the bugs.",

@@ -30,10 +30,6 @@ "main": "lib/superstore-sync.js",

"keywords": [
"localstorage"
"localstorage",
"sessionstorage"
],
"author": "Matt Andrews <matthew.andrews@ft.com>",
"license": "MIT",
"dependencies": {
"setimmediate": "~1.0.1",
"escape-regexp-component": "~1.0"
}
"license": "MIT"
}
# superstore-sync [![Build Status](https://travis-ci.org/matthew-andrews/superstore-sync.png?branch=master)](https://travis-ci.org/matthew-andrews/superstore-sync) [![NPM version](https://badge.fury.io/js/superstore-sync.png)](http://badge.fury.io/js/superstore-sync)
Superstore is a simple lightweight synchronous wrapper around localStorage. Its features include:
Superstore is a simple lightweight synchronous wrapper around the Web Storage APIs [localStorage](https://developer.mozilla.org/en/docs/Web/API/Window/localStorage) and [sessionStorage](https://developer.mozilla.org/en/docs/Web/API/Window/sessionStorage). Its features include:

@@ -8,2 +8,15 @@ - It is [resilient to iOS's strange behaviour in private browsing mode](http://stackoverflow.com/questions/14555347/html5-localstorage-doesnt-works-in-ios-safari-private-browsing).

If you require an asyncronous version please use [superstore](https://github.com/matthew-andrews/superstore) instead.
## install
### NPM
```
npm install superstore-sync --save
```
### bower
```
bower install superstore-sync --save
```
## api

@@ -13,12 +26,35 @@

### #get(key)
## local
### #set(key, value)
### #local.get(key)
### #unset(key)
### #local.set(key, value)
### #clear(prefix)
### #local.unset(key)
### #local.clear(prefix)
## session
### #session.get(key)
### #session.set(key, value)
### #session.unset(key)
### #session.clear(prefix)
## usage
```javascript
var store = require('superstore-sync');
//Persist a value to local storage
var value = store.local.set('foo', 'bar');
//Get a value from session storage
var session = store.session.get('baz');
```
## todo
- JSDoc comments and automatically generating documentation.

Sorry, the diff of this file is not supported yet

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