Skip to content

Commit

Permalink
2.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nbubna committed Dec 18, 2021
1 parent 60502eb commit 21e9005
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 28 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ widgetStore.falsy('state'); // returns true
* 2020-04-14 [v2.11.1][] (public) - Fix falsey alt value support in ```store.get(key, alt)```
* 2020-05-11 [v2.11.2][] (public) - Fix missing TS declaration of new page scope storage.
* 2020-08-12 [v2.12.0][] (public) - PRs for better Storage typing, better testKey, and dev dependency updates.
* 2021-12-16 [v2.13.0][] (public) - Add ```store.set(key, value, replacerFn)```, ```store._replacer```, and ```isFake([force])``` to support stringifying rich types and easier testing. And cookie-based extensions for using store backed by a single 'store' cookie or store API for all cookies.

[v2.0.3]: https://github.com/nbubna/store/tree/2.0.3
[v2.1.0]: https://github.com/nbubna/store/tree/2.1.0
Expand All @@ -251,3 +252,4 @@ widgetStore.falsy('state'); // returns true
[v2.11.1]: https://github.com/nbubna/store/tree/2.11.1
[v2.11.2]: https://github.com/nbubna/store/tree/2.11.2
[v2.12.0]: https://github.com/nbubna/store/tree/2.12.0
[v2.13.0]: https://github.com/nbubna/store/tree/2.13.0
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "store2",
"version": "2.12.0",
"version": "2.13.0",
"main": "dist/store2.js",
"ignore": [
"**/.*",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "store",
"version": "2.12.0",
"version": "2.13.0",
"description": "A better way to use localStorage and sessionStorage",
"repo": "nbubna/store",
"keywords": [
Expand Down
32 changes: 22 additions & 10 deletions dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ require.relative = function(parent) {
return localRequire;
};
require.register("store/dist/store2.js", function(exports, require, module){
/*! store2 - v2.12.0 - 2020-08-12
* Copyright (c) 2020 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
/*! store2 - v2.13.0 - 2021-12-18
* Copyright (c) 2021 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
;(function(window, define) {
var _ = {
version: "2.12.0",
version: "2.13.0",
areas: {},
apis: {},

Expand All @@ -214,8 +214,8 @@ require.register("store/dist/store2.js", function(exports, require, module){
}
return o;
},
stringify: function(d) {
return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d);
stringify: function(d, fn) {
return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d,fn||_.replace);
},
parse: function(s, fn) {
// if it doesn't parse, return as is
Expand Down Expand Up @@ -291,7 +291,15 @@ require.register("store/dist/store2.js", function(exports, require, module){
}
return store;
},
isFake: function(){ return this._area.name === 'fake'; },
isFake: function(force) {
if (force) {
this._real = this._area;
this._area = _.storage('fake');
} else if (force === false) {
this._area = this._real || this._area;
}
return this._area.name === 'fake';
},
toString: function() {
return 'store'+(this._ns?'.'+this.namespace():'')+'['+this._id+']';
},
Expand Down Expand Up @@ -339,11 +347,15 @@ require.register("store/dist/store2.js", function(exports, require, module){
return this;
},
set: function(key, data, overwrite) {
var d = this.get(key);
var d = this.get(key),
replacer;
if (d != null && overwrite === false) {
return data;
}
return _.set(this._area, this._in(key), _.stringify(data), overwrite) || d;
if (typeof overwrite !== "boolean") {
replacer = overwrite;
}
return _.set(this._area, this._in(key), _.stringify(data, replacer)) || d;
},
setAll: function(data, overwrite) {
var changed, val;
Expand All @@ -355,7 +367,7 @@ require.register("store/dist/store2.js", function(exports, require, module){
}
return changed;
},
add: function(key, data) {
add: function(key, data, replacer) {
var d = this.get(key);
if (d instanceof Array) {
data = d.concat(data);
Expand All @@ -370,7 +382,7 @@ require.register("store/dist/store2.js", function(exports, require, module){
data = d + data;
}
}
_.set(this._area, this._in(key), _.stringify(data));
_.set(this._area, this._in(key), _.stringify(data, replacer));
return data;
},
remove: function(key, alt) {
Expand Down
32 changes: 22 additions & 10 deletions dist/store2.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*! store2 - v2.12.0 - 2020-08-12
* Copyright (c) 2020 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
/*! store2 - v2.13.0 - 2021-12-18
* Copyright (c) 2021 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
;(function(window, define) {
var _ = {
version: "2.12.0",
version: "2.13.0",
areas: {},
apis: {},

Expand All @@ -15,8 +15,8 @@
}
return o;
},
stringify: function(d) {
return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d);
stringify: function(d, fn) {
return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d,fn||_.replace);
},
parse: function(s, fn) {
// if it doesn't parse, return as is
Expand Down Expand Up @@ -92,7 +92,15 @@
}
return store;
},
isFake: function(){ return this._area.name === 'fake'; },
isFake: function(force) {
if (force) {
this._real = this._area;
this._area = _.storage('fake');
} else if (force === false) {
this._area = this._real || this._area;
}
return this._area.name === 'fake';
},
toString: function() {
return 'store'+(this._ns?'.'+this.namespace():'')+'['+this._id+']';
},
Expand Down Expand Up @@ -140,11 +148,15 @@
return this;
},
set: function(key, data, overwrite) {
var d = this.get(key);
var d = this.get(key),
replacer;
if (d != null && overwrite === false) {
return data;
}
return _.set(this._area, this._in(key), _.stringify(data), overwrite) || d;
if (typeof overwrite !== "boolean") {
replacer = overwrite;
}
return _.set(this._area, this._in(key), _.stringify(data, replacer)) || d;
},
setAll: function(data, overwrite) {
var changed, val;
Expand All @@ -156,7 +168,7 @@
}
return changed;
},
add: function(key, data) {
add: function(key, data, replacer) {
var d = this.get(key);
if (d instanceof Array) {
data = d.concat(data);
Expand All @@ -171,7 +183,7 @@
data = d + data;
}
}
_.set(this._area, this._in(key), _.stringify(data));
_.set(this._area, this._in(key), _.stringify(data, replacer));
return data;
},
remove: function(key, alt) {
Expand Down
6 changes: 3 additions & 3 deletions dist/store2.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 21e9005

Please sign in to comment.