New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

store2

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

store2 - npm Package Compare versions

Comparing version 2.10.0 to 2.11.0

35

dist/app.js

@@ -200,7 +200,7 @@ ;(function(){

require.register("store/dist/store2.js", function(exports, require, module){
/*! store2 - v2.10.0 - 2019-09-27
* Copyright (c) 2019 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
/*! store2 - v2.11.0 - 2020-03-23
* Copyright (c) 2020 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
;(function(window, define) {
var _ = {
version: "2.10.0",
version: "2.11.0",
areas: {},

@@ -221,5 +221,5 @@ apis: {},

},
parse: function(s) {
parse: function(s, fn) {
// if it doesn't parse, return as is
try{ return JSON.parse(s); }catch(e){ return s; }
try{ return JSON.parse(s,fn||_.revive); }catch(e){ return s; }
},

@@ -326,4 +326,9 @@

get: function(key, alt) {
var s = _.get(this._area, this._in(key));
return s !== null ? _.parse(s) : alt || s;// support alt for easy default mgmt
var s = _.get(this._area, this._in(key)),
fn;
if (typeof alt === "function") {
fn = alt;
alt = null;
}
return s !== null ? _.parse(s, fn) : alt || s;// support alt for easy default mgmt
},

@@ -491,7 +496,9 @@ getAll: function(fillObj) {

if (!fn) { fn = key; key = ''; }// no key === all keys
var listener = function(e) {
var k = this._out(e.key);// undefined if key is not in the namespace
if ((k && (!key || k === key)) && // match key if listener has one
(!e.storageArea || e.storageArea === this._area)) {// match area, if available
return fn.call(this, _.event.call(this, k, e));
var s = this,
listener = function(e) {
var k = s._out(e.key);// undefined if key is not in the namespace
if ((k && (k === key ||// match key if listener has one
(!key && k !== '_-bad-_'))) &&// match catch-all, except internal test
(!e.storageArea || e.storageArea === s._area)) {// match area, if available
return fn.call(s, _.event.call(s, k, e));
}

@@ -566,7 +573,7 @@ };

_set = _.set;
_.parse = function(s) {
_.parse = function(s, fn) {
if (s && s.indexOf(prefix) === 0) {
s = s.substring(s.indexOf(suffix)+1);
}
return parse(s);
return parse(s, fn);
};

@@ -573,0 +580,0 @@ _.expires = function(s) {

19

dist/store2.js

@@ -1,6 +0,6 @@

/*! store2 - v2.10.0 - 2019-09-27
* Copyright (c) 2019 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
/*! store2 - v2.11.0 - 2020-03-23
* Copyright (c) 2020 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
;(function(window, define) {
var _ = {
version: "2.10.0",
version: "2.11.0",
areas: {},

@@ -21,5 +21,5 @@ apis: {},

},
parse: function(s) {
parse: function(s, fn) {
// if it doesn't parse, return as is
try{ return JSON.parse(s); }catch(e){ return s; }
try{ return JSON.parse(s,fn||_.revive); }catch(e){ return s; }
},

@@ -126,4 +126,9 @@

get: function(key, alt) {
var s = _.get(this._area, this._in(key));
return s !== null ? _.parse(s) : alt || s;// support alt for easy default mgmt
var s = _.get(this._area, this._in(key)),
fn;
if (typeof alt === "function") {
fn = alt;
alt = null;
}
return s !== null ? _.parse(s, fn) : alt || s;// support alt for easy default mgmt
},

@@ -130,0 +135,0 @@ getAll: function(fillObj) {

@@ -1,5 +0,5 @@

/*! store2 - v2.10.0 - 2019-09-27
* Copyright (c) 2019 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
/*! store2 - v2.11.0 - 2020-03-23
* Copyright (c) 2020 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
!function(a,b){var c={version:"2.10.0",areas:{},apis:{},inherit:function(a,b){for(var c in a)b.hasOwnProperty(c)||Object.defineProperty(b,c,Object.getOwnPropertyDescriptor(a,c));return b},stringify:function(a){return void 0===a||"function"==typeof a?a+"":JSON.stringify(a)},parse:function(a){try{return JSON.parse(a)}catch(b){return a}},fn:function(a,b){c.storeAPI[a]=b;for(var d in c.apis)c.apis[d][a]=b},get:function(a,b){return a.getItem(b)},set:function(a,b,c){a.setItem(b,c)},remove:function(a,b){a.removeItem(b)},key:function(a,b){return a.key(b)},length:function(a){return a.length},clear:function(a){a.clear()},Store:function(a,b,d){var e=c.inherit(c.storeAPI,function(a,b,c){return 0===arguments.length?e.getAll():"function"==typeof b?e.transact(a,b,c):void 0!==b?e.set(a,b,c):"string"==typeof a||"number"==typeof a?e.get(a):"function"==typeof a?e.each(a):a?e.setAll(a,b):e.clear()});e._id=a;try{b.setItem("_-bad-_","wolf"),e._area=b,b.removeItem("_-bad-_")}catch(a){}return e._area||(e._area=c.storage("fake")),e._ns=d||"",c.areas[a]||(c.areas[a]=e._area),c.apis[e._ns+e._id]||(c.apis[e._ns+e._id]=e),e},storeAPI:{area:function(a,b){var d=this[a];return d&&d.area||(d=c.Store(a,b,this._ns),this[a]||(this[a]=d)),d},namespace:function(a,b){if(!a)return this._ns?this._ns.substring(0,this._ns.length-1):"";var d=a,e=this[d];if(!(e&&e.namespace||(e=c.Store(this._id,this._area,this._ns+d+"."),this[d]||(this[d]=e),b)))for(var f in c.areas)e.area(f,c.areas[f]);return e},isFake:function(){return"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(a){return this._area.has?this._area.has(this._in(a)):!!(this._in(a)in this._area)},size:function(){return this.keys().length},each:function(a,b){for(var d=0,e=c.length(this._area);d<e;d++){var f=this._out(c.key(this._area,d));if(void 0!==f&&!1===a.call(this,f,this.get(f),b))break;e>c.length(this._area)&&(e--,d--)}return b||this},keys:function(a){return this.each(function(a,b,c){c.push(a)},a||[])},get:function(a,b){var d=c.get(this._area,this._in(a));return null!==d?c.parse(d):b||d},getAll:function(a){return this.each(function(a,b,c){c[a]=b},a||{})},transact:function(a,b,c){var d=this.get(a,c),e=b(d);return this.set(a,void 0===e?d:e),this},set:function(a,b,d){var e=this.get(a);return null!=e&&!1===d?b:c.set(this._area,this._in(a),c.stringify(b),d)||e},setAll:function(a,b){var c,d;for(var e in a)d=a[e],this.set(e,d,b)!==d&&(c=!0);return c},add:function(a,b){var d=this.get(a);if(d instanceof Array)b=d.concat(b);else if(null!==d){var e=typeof d;if(e===typeof b&&"object"===e){for(var f in b)d[f]=b[f];b=d}else b=d+b}return c.set(this._area,this._in(a),c.stringify(b)),b},remove:function(a,b){var d=this.get(a,b);return c.remove(this._area,this._in(a)),d},clear:function(){return this._ns?this.each(function(a){c.remove(this._area,this._in(a))},1):c.clear(this._area),this},clearAll:function(){var a=this._area;for(var b in c.areas)c.areas.hasOwnProperty(b)&&(this._area=c.areas[b],this.clear());return this._area=a,this},_in:function(a){return"string"!=typeof a&&(a=c.stringify(a)),this._ns?this._ns+a:a},_out:function(a){return this._ns?a&&0===a.indexOf(this._ns)?a.substring(this._ns.length):void 0:a}},storage:function(a){return c.inherit(c.storageAPI,{items:{},name:a})},storageAPI:{length:0,has:function(a){return this.items.hasOwnProperty(a)},key:function(a){var b=0;for(var c in this.items)if(this.has(c)&&a===b++)return c},setItem:function(a,b){this.has(a)||this.length++,this.items[a]=b},removeItem:function(a){this.has(a)&&(delete this.items[a],this.length--)},getItem:function(a){return this.has(a)?this.items[a]:null},clear:function(){for(var a in this.items)this.removeItem(a)}}},d=c.Store("local",function(){try{return localStorage}catch(a){}}());d.local=d,d._=c,d.area("session",function(){try{return sessionStorage}catch(a){}}()),d.area("page",c.storage("page")),"function"==typeof b&&void 0!==b.amd?b("store2",[],function(){return d}):"undefined"!=typeof module&&module.exports?module.exports=d:(a.store&&(c.conflict=a.store),a.store=d)}(this,this&&this.define);
!function(a,b){var c={version:"2.11.0",areas:{},apis:{},inherit:function(a,b){for(var c in a)b.hasOwnProperty(c)||Object.defineProperty(b,c,Object.getOwnPropertyDescriptor(a,c));return b},stringify:function(a){return void 0===a||"function"==typeof a?a+"":JSON.stringify(a)},parse:function(a,b){try{return JSON.parse(a,b||c.revive)}catch(b){return a}},fn:function(a,b){c.storeAPI[a]=b;for(var d in c.apis)c.apis[d][a]=b},get:function(a,b){return a.getItem(b)},set:function(a,b,c){a.setItem(b,c)},remove:function(a,b){a.removeItem(b)},key:function(a,b){return a.key(b)},length:function(a){return a.length},clear:function(a){a.clear()},Store:function(a,b,d){var e=c.inherit(c.storeAPI,function(a,b,c){return 0===arguments.length?e.getAll():"function"==typeof b?e.transact(a,b,c):void 0!==b?e.set(a,b,c):"string"==typeof a||"number"==typeof a?e.get(a):"function"==typeof a?e.each(a):a?e.setAll(a,b):e.clear()});e._id=a;try{b.setItem("_-bad-_","wolf"),e._area=b,b.removeItem("_-bad-_")}catch(a){}return e._area||(e._area=c.storage("fake")),e._ns=d||"",c.areas[a]||(c.areas[a]=e._area),c.apis[e._ns+e._id]||(c.apis[e._ns+e._id]=e),e},storeAPI:{area:function(a,b){var d=this[a];return d&&d.area||(d=c.Store(a,b,this._ns),this[a]||(this[a]=d)),d},namespace:function(a,b){if(!a)return this._ns?this._ns.substring(0,this._ns.length-1):"";var d=a,e=this[d];if(!(e&&e.namespace||(e=c.Store(this._id,this._area,this._ns+d+"."),this[d]||(this[d]=e),b)))for(var f in c.areas)e.area(f,c.areas[f]);return e},isFake:function(){return"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(a){return this._area.has?this._area.has(this._in(a)):!!(this._in(a)in this._area)},size:function(){return this.keys().length},each:function(a,b){for(var d=0,e=c.length(this._area);d<e;d++){var f=this._out(c.key(this._area,d));if(void 0!==f&&!1===a.call(this,f,this.get(f),b))break;e>c.length(this._area)&&(e--,d--)}return b||this},keys:function(a){return this.each(function(a,b,c){c.push(a)},a||[])},get:function(a,b){var d,e=c.get(this._area,this._in(a));return"function"==typeof b&&(d=b,b=null),null!==e?c.parse(e,d):b||e},getAll:function(a){return this.each(function(a,b,c){c[a]=b},a||{})},transact:function(a,b,c){var d=this.get(a,c),e=b(d);return this.set(a,void 0===e?d:e),this},set:function(a,b,d){var e=this.get(a);return null!=e&&!1===d?b:c.set(this._area,this._in(a),c.stringify(b),d)||e},setAll:function(a,b){var c,d;for(var e in a)d=a[e],this.set(e,d,b)!==d&&(c=!0);return c},add:function(a,b){var d=this.get(a);if(d instanceof Array)b=d.concat(b);else if(null!==d){var e=typeof d;if(e===typeof b&&"object"===e){for(var f in b)d[f]=b[f];b=d}else b=d+b}return c.set(this._area,this._in(a),c.stringify(b)),b},remove:function(a,b){var d=this.get(a,b);return c.remove(this._area,this._in(a)),d},clear:function(){return this._ns?this.each(function(a){c.remove(this._area,this._in(a))},1):c.clear(this._area),this},clearAll:function(){var a=this._area;for(var b in c.areas)c.areas.hasOwnProperty(b)&&(this._area=c.areas[b],this.clear());return this._area=a,this},_in:function(a){return"string"!=typeof a&&(a=c.stringify(a)),this._ns?this._ns+a:a},_out:function(a){return this._ns?a&&0===a.indexOf(this._ns)?a.substring(this._ns.length):void 0:a}},storage:function(a){return c.inherit(c.storageAPI,{items:{},name:a})},storageAPI:{length:0,has:function(a){return this.items.hasOwnProperty(a)},key:function(a){var b=0;for(var c in this.items)if(this.has(c)&&a===b++)return c},setItem:function(a,b){this.has(a)||this.length++,this.items[a]=b},removeItem:function(a){this.has(a)&&(delete this.items[a],this.length--)},getItem:function(a){return this.has(a)?this.items[a]:null},clear:function(){for(var a in this.items)this.removeItem(a)}}},d=c.Store("local",function(){try{return localStorage}catch(a){}}());d.local=d,d._=c,d.area("session",function(){try{return sessionStorage}catch(a){}}()),d.area("page",c.storage("page")),"function"==typeof b&&void 0!==b.amd?b("store2",[],function(){return d}):"undefined"!=typeof module&&module.exports?module.exports=d:(a.store&&(c.conflict=a.store),a.store=d)}(this,this&&this.define);
//# sourceMappingURL=store2.min.js.map
{
"name": "store2",
"version": "2.10.0",
"version": "2.11.0",
"description": "Better localStorage",

@@ -5,0 +5,0 @@ "keywords": [

@@ -18,3 +18,3 @@ A feature-filled and friendly way to take advantage of localStorage and sessionStorage

## Documentation
The main store function can handle ```set```, ```get```, ```transact```, ```setAll```, ```getAll``` and ```clear```
The main store function can handle ```set```, ```get```, ```transact```, ```setAll```, ```getAll```, ```each```, and ```clear```
actions directly. Respectively, these are called like so:

@@ -55,2 +55,4 @@

All functions which take an optional ```alt``` parameter can also use that parameter to specify a "reviver" function. These receive each key and value (yes, nested ones too) as arguments and allow you to provide an alternate means of parsing that string. This is particularly useful for rich objects like ```Date``` types. See [MDN's JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) for more information and examples. Alternately, you can set a global reviver to the ```store._.revive``` property to handle all ```get```, ```getAll```, and ```transact``` calls.
Functions passed to ```transact``` will receive the current value for that key as an argument or

@@ -219,2 +221,3 @@ a passed alternate if there is none. When the passed function is completed, transact will save the returned value

* 2019-09-27 [v2.10.0][] (public) - Add ```store.page``` to provide page scope storage to complement local and session scope storage. (Issue #69)
* 2020-03-23 [v2.11.0][] (public) - Add ```store.get(key, reviveFn)``` and ```store._.revive`` to support parsing for rich types (e.g. Date)

@@ -240,1 +243,2 @@ [v2.0.3]: https://github.com/nbubna/store/tree/2.0.3

[v2.10.0]: https://github.com/nbubna/store/tree/2.10.0
[v2.11.0]: https://github.com/nbubna/store/tree/2.11.0

@@ -18,7 +18,7 @@ /**

_set = _.set;
_.parse = function(s) {
_.parse = function(s, fn) {
if (s && s.indexOf(prefix) === 0) {
s = s.substring(s.indexOf(suffix)+1);
}
return parse(s);
return parse(s, fn);
};

@@ -25,0 +25,0 @@ _.expires = function(s) {

@@ -24,7 +24,9 @@ /**

if (!fn) { fn = key; key = ''; }// no key === all keys
var listener = function(e) {
var k = this._out(e.key);// undefined if key is not in the namespace
if ((k && (!key || k === key)) && // match key if listener has one
(!e.storageArea || e.storageArea === this._area)) {// match area, if available
return fn.call(this, _.event.call(this, k, e));
var s = this,
listener = function(e) {
var k = s._out(e.key);// undefined if key is not in the namespace
if ((k && (k === key ||// match key if listener has one
(!key && k !== '_-bad-_'))) &&// match catch-all, except internal test
(!e.storageArea || e.storageArea === s._area)) {// match area, if available
return fn.call(s, _.event.call(s, k, e));
}

@@ -31,0 +33,0 @@ };

@@ -25,5 +25,5 @@ /**

},
parse: function(s) {
parse: function(s, fn) {
// if it doesn't parse, return as is
try{ return JSON.parse(s); }catch(e){ return s; }
try{ return JSON.parse(s,fn||_.revive); }catch(e){ return s; }
},

@@ -130,4 +130,9 @@

get: function(key, alt) {
var s = _.get(this._area, this._in(key));
return s !== null ? _.parse(s) : alt || s;// support alt for easy default mgmt
var s = _.get(this._area, this._in(key)),
fn;
if (typeof alt === "function") {
fn = alt;
alt = null;
}
return s !== null ? _.parse(s, fn) : alt || s;// support alt for easy default mgmt
},

@@ -134,0 +139,0 @@ getAll: function(fillObj) {

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