Comparing version 2.5.9 to 2.5.10
@@ -200,7 +200,7 @@ ;(function(){ | ||
require.register("store/dist/store2.js", function(exports, require, module){ | ||
/*! store2 - v2.5.9 - 2017-10-26 | ||
* Copyright (c) 2017 Nathan Bubna; Licensed (MIT OR GPL-3.0) */ | ||
/*! store2 - v2.5.10 - 2018-01-18 | ||
* Copyright (c) 2018 Nathan Bubna; Licensed (MIT OR GPL-3.0) */ | ||
;(function(window, define) { | ||
var _ = { | ||
version: "2.5.9", | ||
version: "2.5.10", | ||
areas: {}, | ||
@@ -207,0 +207,0 @@ apis: {}, |
@@ -1,6 +0,6 @@ | ||
/*! store2 - v2.5.9 - 2017-10-26 | ||
* Copyright (c) 2017 Nathan Bubna; Licensed (MIT OR GPL-3.0) */ | ||
/*! store2 - v2.5.10 - 2018-01-18 | ||
* Copyright (c) 2018 Nathan Bubna; Licensed (MIT OR GPL-3.0) */ | ||
;(function(window, define) { | ||
var _ = { | ||
version: "2.5.9", | ||
version: "2.5.10", | ||
areas: {}, | ||
@@ -7,0 +7,0 @@ apis: {}, |
@@ -1,5 +0,5 @@ | ||
/*! store2 - v2.5.9 - 2017-10-26 | ||
* Copyright (c) 2017 Nathan Bubna; Licensed (MIT OR GPL-3.0) */ | ||
/*! store2 - v2.5.10 - 2018-01-18 | ||
* Copyright (c) 2018 Nathan Bubna; Licensed (MIT OR GPL-3.0) */ | ||
!function(a,b){var c={version:"2.5.9",areas:{},apis:{},inherit:function(a,b){for(var c in a)b.hasOwnProperty(c)||(b[c]=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):a?e.setAll(a,b):e.clear()});e._id=a;try{b.setItem("_safariPrivate_","sucks"),e._area=b,b.removeItem("_safariPrivate_")}catch(a){}return e._area||(e._area=c.inherit(c.storageAPI,{items:{},name:"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];return e&&e.namespace||(e=c.Store(this._id,this._area,this._ns+d+"."),this[d]||(this[d]=e),b||e.area("session",c.areas.session)),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&&a.call(this,f,b||this.get(f))===!1)break;e>c.length(this._area)&&(e--,d--)}return b||this},keys:function(){return this.each(function(a,b){b.push(a)},[])},get:function(a,b){var d=c.get(this._area,this._in(a));return null!==d?c.parse(d):b||d},getAll:function(){return this.each(function(a,b){b[a]=this.get(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&&d===!1?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},remove:function(a){var b=this.get(a);return c.remove(this._area,this._in(a)),b},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}},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)},toString:function(){return this.length+" items in "+this.name+"Storage"}}},d=c.Store("local",function(){try{return localStorage}catch(a){}}());d.local=d,d._=c,d.area("session",function(){try{return sessionStorage}catch(a){}}()),"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.define); | ||
!function(a,b){var c={version:"2.5.10",areas:{},apis:{},inherit:function(a,b){for(var c in a)b.hasOwnProperty(c)||(b[c]=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):a?e.setAll(a,b):e.clear()});e._id=a;try{b.setItem("_safariPrivate_","sucks"),e._area=b,b.removeItem("_safariPrivate_")}catch(a){}return e._area||(e._area=c.inherit(c.storageAPI,{items:{},name:"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];return e&&e.namespace||(e=c.Store(this._id,this._area,this._ns+d+"."),this[d]||(this[d]=e),b||e.area("session",c.areas.session)),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&&a.call(this,f,b||this.get(f))===!1)break;e>c.length(this._area)&&(e--,d--)}return b||this},keys:function(){return this.each(function(a,b){b.push(a)},[])},get:function(a,b){var d=c.get(this._area,this._in(a));return null!==d?c.parse(d):b||d},getAll:function(){return this.each(function(a,b){b[a]=this.get(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&&d===!1?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},remove:function(a){var b=this.get(a);return c.remove(this._area,this._in(a)),b},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}},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)},toString:function(){return this.length+" items in "+this.name+"Storage"}}},d=c.Store("local",function(){try{return localStorage}catch(a){}}());d.local=d,d._=c,d.area("session",function(){try{return sessionStorage}catch(a){}}()),"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.define); | ||
//# sourceMappingURL=store2.min.js.map |
106
index.d.ts
@@ -1,59 +0,59 @@ | ||
export function store(key: any, fn: (data: any) => any, alt?: any): StoreAPI | ||
export function store(key: any, data: any): any | ||
export function store(clearIfFalsy: false | 0): StoreAPI | ||
export function store(key: any): any | ||
export function store(obj: Object): StoredData | ||
export function store(): StoredData | ||
declare namespace store { | ||
const local : StoreAPI; | ||
const session : StoreAPI; | ||
// if anyone knows a way to avoid duplicating the StoreAPI interface here that'd be great | ||
export namespace store { | ||
const local: StoreAPI; | ||
const session: StoreAPI; | ||
function area(id: string, area: Storage): StoreAPI; | ||
function set(key: any, data: any, overwrite?: boolean): any; | ||
function setAll(data: Object, overwrite?: boolean): StoredData; | ||
function get(key: any, alt?: any): any; | ||
function getAll(): StoredData; | ||
function transact(key: any, fn: (data: any) => any, alt?: any): StoreAPI; | ||
function clear(): StoreAPI; | ||
function has(key: any): boolean; | ||
function remove(key: any): any; | ||
function each(callback: (key: any, data: any) => false | any): StoreAPI; | ||
function keys(): string[]; | ||
function size(): number; | ||
function clearAll(): StoreAPI; | ||
function isFake(): boolean; | ||
function namespace(namespace: string, noSession?: true): StoreAPI; | ||
} | ||
function area (id : string, area : Storage) : StoreAPI; | ||
function set (key : any, data : any, overwrite? : boolean) : any; | ||
function setAll (data : Object, overwrite? : boolean) : StoredData; | ||
function get (key : any, alt? : any) : any; | ||
function getAll () : StoredData; | ||
function transact (key : any, fn : (data : any) => any, alt? : any) : StoreAPI; | ||
function clear () : StoreAPI; | ||
function has (key : any) : boolean; | ||
function remove (key : any) : any; | ||
function each (callback : (key : any, data : any) => false | any) : StoreAPI; | ||
function keys () : string[]; | ||
function size () : number; | ||
function clearAll () : StoreAPI; | ||
function isFake () : boolean; | ||
function namespace (namespace : string, noSession? : true) : StoreAPI; | ||
export interface StoreAPI { | ||
set(key: any, data: any, overwrite?: boolean): any; | ||
setAll(data: Object, overwrite?: boolean): StoredData; | ||
get(key: any, alt?: any): any; | ||
getAll(): StoredData; | ||
transact(key: any, fn: (data: any) => any, alt?: any): StoreAPI; | ||
clear(): StoreAPI; | ||
has(key: any): boolean; | ||
remove(key: any): any; | ||
each(callback: (key: any, data: any) => false | any): StoreAPI; | ||
keys(): string[]; | ||
size(): number; | ||
clearAll(): StoreAPI; | ||
isFake(): boolean; | ||
namespace(namespace: string, noSession?: true): StoreAPI; | ||
} | ||
export interface StoreAPI { | ||
clear() : StoreAPI; | ||
clearAll() : StoreAPI; | ||
each(callback : (key : any, data : any) => false | any) : StoreAPI; | ||
get(key : any, alt? : any) : any; | ||
getAll() : StoredData; | ||
has(key : any) : boolean; | ||
isFake() : boolean; | ||
keys() : string[]; | ||
namespace(namespace : string, noSession? : true) : StoreAPI; | ||
remove(key : any) : any; | ||
set(key : any, data : any, overwrite? : boolean) : any; | ||
setAll(data : Object, overwrite? : boolean) : StoredData; | ||
size() : number; | ||
transact(key : any, fn : (data : any) => any, alt? : any) : StoreAPI; | ||
} | ||
export interface StoredData { | ||
[key: string]: any; | ||
} | ||
export interface StoredData { | ||
[key : string] : any; | ||
} | ||
export interface Storage { | ||
getItem(key: string): string; | ||
setItem(key: string, value: string): void; | ||
removeItem(key: string): void; | ||
key(index: number): string; | ||
length: number; | ||
clear(): void; | ||
export interface Storage { | ||
length : number; | ||
clear() : void; | ||
getItem(key : string) : string; | ||
key(index : number) : string; | ||
removeItem(key : string) : void; | ||
setItem(key : string, value : string) : void; | ||
} | ||
} | ||
export default store; | ||
declare function store (key : any, fn : (data : any) => any, alt? : any) : store.StoreAPI | ||
declare function store (key : any, data : any) : any | ||
declare function store (clearIfFalsy : false | 0) : store.StoreAPI | ||
declare function store (key : any) : any | ||
declare function store (obj : Object) : store.StoredData | ||
declare function store () : store.StoredData | ||
export = store; |
{ | ||
"name": "store2", | ||
"version": "2.5.9", | ||
"version": "2.5.10", | ||
"description": "Better localStorage", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
"scripts": { | ||
"prepublish": "grunt && git commit -m \"$npm_package_version\" README.md *.json dist && git tag $npm_package_version && git push && git push --tags", | ||
"prepublishOnly": "grunt && git commit -m \"$npm_package_version\" README.md *.json dist && git tag $npm_package_version && git push && git push --tags", | ||
"test": "grunt qunit" | ||
@@ -40,0 +40,0 @@ }, |
@@ -143,6 +143,3 @@ A feature-filled and friendly way to take advantage of localStorage and sessionStorage | ||
* 2013-05-30 [v2.1.2][] (public) - Component support (old component.json is now bower.json) | ||
* 2013-09-08 [v2.1.3][] (public) - Remove unnecessary component.js shim | ||
* 2014-03-01 [v2.1.4][] (public) - Package definition and store.overflow.js updates | ||
* 2014-03-06 [v2.1.5][] (public) - AMD support and Component improvements | ||
* 2014-03-10 [v2.1.6][] (public) - Fix AMD support flaw | ||
* 2014-03-10 [v2.1.6][] (public) - AMD support and Component improvements | ||
* 2015-02-02 [v2.2.0][] (public) - Change store.cache.js to use seconds, not minutes. | ||
@@ -155,5 +152,4 @@ * 2015-05-05 [v2.2.1][] (public) - node.js compatibility | ||
* 2017-01-09 [v2.5.0][] (public) - Update for issue #34; new extensions (array, dot, and deep); only expose global in non-AMD/CommonJS environments (PR #35) | ||
* 2017-03-28 [v2.5.1][] (public) - Lint fixes, dependency updates | ||
* 2017-08-09 [v2.5.2][] (public) - Fix `clear()` in fake storage (thx to Martin Kluska) | ||
* 2017-10-26 [v2.5.9][] (public) - Add ```index.d.ts``` in root to provide TypeScript support (thx to Anton Strömkvist) | ||
* 2018-01-18 [v2.5.9][] (public) - Add ```index.d.ts``` in root to provide TypeScript support | ||
@@ -164,5 +160,2 @@ [v2.0.3]: https://github.com/nbubna/store/tree/2.0.3 | ||
[v2.1.2]: https://github.com/nbubna/store/tree/2.1.2 | ||
[v2.1.3]: https://github.com/nbubna/store/tree/2.1.3 | ||
[v2.1.4]: https://github.com/nbubna/store/tree/2.1.4 | ||
[v2.1.5]: https://github.com/nbubna/store/tree/2.1.5 | ||
[v2.1.6]: https://github.com/nbubna/store/tree/2.1.6 | ||
@@ -176,19 +169,16 @@ [v2.2.0]: https://github.com/nbubna/store/tree/2.2.0 | ||
[v2.5.0]: https://github.com/nbubna/store/tree/2.5.0 | ||
[v2.5.1]: https://github.com/nbubna/store/tree/2.5.1 | ||
[v2.5.2]: https://github.com/nbubna/store/tree/2.5.2 | ||
[v2.5.9]: https://github.com/nbubna/store/tree/2.5.9 | ||
[v2.5.10]: https://github.com/nbubna/store/tree/2.5.10 | ||
## Store vs Store | ||
When i went to publish this on NPM i discovered another [store.js][other] by Marcus Westin. | ||
To my surprise, even our APIs had notable overlap. His has fewer features and includes superior support | ||
for IE 6/7 in the main lib. I contacted him with the idea of merging the featuresets, but we agreed it wouldn't work. | ||
He saw his library as a temporary polyfill meant to fade away with IE 6/7. This project is meant | ||
to always be useful, as a better way to use localStorage, with polyfilling as an extension. I do hope | ||
to incorporate IE 6/7 improvements from the other store.js into store.old.js at some point, | ||
but it is not a priority. | ||
To my pleasure, even our APIs had notable overlap, but his had fewer features and a focus on polyfilling old | ||
browsers (e.g. IE 6/7). He saw the library at the time as a temporary polyfill, while i intended mine | ||
to always be a better way to use localStorage and sessionStorage. We discussed merging the featuresets, | ||
but we agreed it wouldn't work due to different goals. To minimize confusion, i published this as 'store2', | ||
but kept the main function as `store`. Marcus' later decision to pivot and adopt the goals and many of | ||
the features of this library into a v2 of store.js has put these libraries into more direct competition. | ||
I believe this library to be superior in implementation and interface, though not in all aspects and the | ||
differences are admittedly small. There is still potential for unification, perhaps in a v3 someday. | ||
To minimize confusion, i will be publishing the library as 'store2', | ||
but the main function will always be `store`. | ||
My apologies for the confusion caused while i was publishing this as another 'store'. | ||
[other]: https://github.com/marcuswestin/store.js/ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100220
2144
181