@ngx-pwa/local-storage
Advanced tools
Comparing version 6.0.0-rc.0 to 6.0.0-rc.1
@@ -56,5 +56,2 @@ (function (global, factory) { | ||
} | ||
if (prefix) { | ||
this.dbName = prefix + "_" + this.dbName; | ||
} | ||
/* Creating the RxJS ReplaySubject */ | ||
@@ -61,0 +58,0 @@ this.database = new rxjs.ReplaySubject(); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common","rxjs","rxjs/operators"],t):t((e.ngxPWA=e.ngxPWA||{},e.ngxPWA.localStorage=e.ngxPWA.localStorage||{}),e.ng.core,e.ng.common,e.Rx,e.Rx.operators)}(this,function(e,t,r,n,o){"use strict";function i(e,t){return r.isPlatformBrowser(e)&&"indexedDB"in window&&void 0!==indexedDB&&null!==indexedDB?new u(t):r.isPlatformBrowser(e)&&"localStorage"in window&&void 0!==localStorage&&null!==localStorage?new s(t):new c}var a=new t.InjectionToken("localStoragePrefix",{providedIn:"root",factory:function(){return""}}),u=function(){function e(e){void 0===e&&(e=null),this.prefix=e,this.dbName="ngStorage",this.objectStoreName="localStorage",this.keyPath="key",this.dataPath="value",e&&(this.dbName=e+"_"+this.dbName),e&&(this.dbName=e+"_"+this.dbName),this.database=new n.ReplaySubject,this.connect()}return e.prototype.getItem=function(e){var t=this;return this.transaction().pipe(o.map(function(t){return t.get(e)}),o.mergeMap(function(e){var r=n.fromEvent(e,"success").pipe(o.map(function(e){return e.target.result}),o.map(function(e){return e&&t.dataPath in e?e[t.dataPath]:null}));return n.race(r,t.toErrorObservable(e,"getter")).pipe(o.first())}),o.first())},e.prototype.setItem=function(e,t){var r=this;return null==t?n.of(!0):this.getItem(e).pipe(o.map(function(e){return null==e?"add":"put"}),o.mergeMap(function(i){return r.transaction("readwrite").pipe(o.mergeMap(function(a){var u;switch(i){case"add":u=a.add((s={},s[r.dataPath]=t,s),e);break;case"put":default:u=a.put((c={},c[r.dataPath]=t,c),e)}return n.race(r.toSuccessObservable(u),r.toErrorObservable(u,"setter")).pipe(o.first());var s,c}))}),o.first())},e.prototype.removeItem=function(e){var t=this;return this.getItem(e).pipe(o.mergeMap(function(r){return null!=r?t.transaction("readwrite").pipe(o.mergeMap(function(r){var i=r.delete(e);return n.race(t.toSuccessObservable(i),t.toErrorObservable(i,"remover")).pipe(o.first())})):n.of(!0)}),o.first())},e.prototype.clear=function(){var e=this;return this.transaction("readwrite").pipe(o.mergeMap(function(t){var r=t.clear();return n.race(e.toSuccessObservable(r),e.toErrorObservable(r,"clearer")).pipe(o.first())}),o.first())},e.prototype.connect=function(){var e=this,t=indexedDB.open(this.dbName);n.fromEvent(t,"upgradeneeded").pipe(o.first()).subscribe(function(t){var r=t.target.result;r.objectStoreNames.contains(e.objectStoreName)||r.createObjectStore(e.objectStoreName)});var r=n.fromEvent(t,"success");n.race(r,this.toErrorObservable(t,"connection")).pipe(o.first()).subscribe(function(t){e.database.next(t.target.result)},function(t){e.database.error(t)})},e.prototype.transaction=function(e){var t=this;return void 0===e&&(e="readonly"),this.database.pipe(o.map(function(r){return r.transaction([t.objectStoreName],e).objectStore(t.objectStoreName)}))},e.prototype.toSuccessObservable=function(e){return n.fromEvent(e,"success").pipe(o.map(function(){return!0}))},e.prototype.toErrorObservable=function(e,t){return void 0===t&&(t=""),n.fromEvent(e,"error").pipe(o.mergeMap(function(r){return n.throwError(new Error("IndexedDB "+t+" issue : "+e.error.message+"."))}))},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[a]}]}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(a,8))},token:e,providedIn:"root"}),e}(),s=function(){function e(e){void 0===e&&(e=null),this.userPrefix=e,this.prefix="",e&&(this.prefix=e+"_")}return e.prototype.getItem=function(e){var t=localStorage.getItem(""+this.prefix+e),r=null;if(null!=t)try{r=JSON.parse(t)}catch(e){return n.throwError(new Error("Invalid data in localStorage."))}return n.of(r)},e.prototype.setItem=function(e,t){return localStorage.setItem(""+this.prefix+e,JSON.stringify(t)),n.of(!0)},e.prototype.removeItem=function(e){return localStorage.removeItem(""+this.prefix+e),n.of(!0)},e.prototype.clear=function(){return localStorage.clear(),n.of(!0)},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[a]}]}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(a,8))},token:e,providedIn:"root"}),e}(),c=function(){function e(){this.localStorage=new Map}return e.prototype.getItem=function(e){var t=this.localStorage.get(e);return n.of(void 0!==t?t:null)},e.prototype.setItem=function(e,t){return this.localStorage.set(e,t),n.of(!0)},e.prototype.removeItem=function(e){return this.localStorage.delete(e),n.of(!0)},e.prototype.clear=function(){return this.localStorage.clear(),n.of(!0)},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),p=function(){function e(){}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root",useFactory:i,deps:[t.PLATFORM_ID,[new t.Optional,a]]}]}],e.ngInjectableDef=t.defineInjectable({factory:function(){return i(t.inject(t.PLATFORM_ID),t.inject(a,8))},token:e,providedIn:"root"}),e}(),l=function(){function e(){}return e.prototype.validate=function(e,t){if(!((t.hasOwnProperty("const")&&void 0!==t.const||t.hasOwnProperty("enum")&&null!=t.enum||t.hasOwnProperty("type")&&null!=t.type)&&"array"!==t.type&&"object"!==t.type||t.hasOwnProperty("properties")&&null!=t.properties||t.hasOwnProperty("items")&&null!=t.items))throw new Error("Each value must have a 'type' or 'properties' or 'items' or 'const' or 'enum', to enforce strict types.");return(!t.hasOwnProperty("const")||void 0===t.const||e===t.const)&&(!!this.validateEnum(e,t)&&(!!this.validateType(e,t)&&(!!this.validateItems(e,t)&&(!!this.validateProperties(e,t)&&!!this.validateRequired(e,t)))))},e.prototype.isObjectNotNull=function(e){return null!==e&&"object"==typeof e},e.prototype.validateProperties=function(e,t){if(!t.hasOwnProperty("properties")||null==t.properties)return!0;if(!this.isObjectNotNull(e))return!1;if(Object.keys(t.properties).length!==Object.keys(e).length)return!1;for(var r in t.properties)if(t.properties.hasOwnProperty(r)&&e.hasOwnProperty(r)&&!this.validate(e[r],t.properties[r]))return!1;return!0},e.prototype.validateRequired=function(e,t){if(!t.hasOwnProperty("required")||null==t.required)return!0;if(!this.isObjectNotNull(e))return!1;for(var r=0,n=t.required;r<n.length;r++){var o=n[r];if(!t.properties||!t.properties.hasOwnProperty(o))throw new Error("'required' properties must be described in 'properties' too.");if(!e.hasOwnProperty(o))return!1}return!0},e.prototype.validateEnum=function(e,t){return!t.hasOwnProperty("enum")||null==t.enum||-1!==t.enum.indexOf(e)},e.prototype.validateType=function(e,t){if(!t.hasOwnProperty("type")||null==t.type)return!0;switch(t.type){case"null":return null===e;case"string":return this.validateString(e,t);case"number":case"integer":return this.validateNumber(e,t);case"boolean":return"boolean"==typeof e;case"object":return"object"==typeof e;case"array":return Array.isArray(e)}},e.prototype.validateItems=function(e,t){if(!t.hasOwnProperty("items")||null==t.items)return!0;if(!Array.isArray(e))return!1;if(t.hasOwnProperty("maxItems")&&null!=t.maxItems){if(!Number.isInteger(t.maxItems)||t.maxItems<0)throw new Error("'maxItems' must be a non-negative integer.");if(e.length>t.maxItems)return!1}if(t.hasOwnProperty("minItems")&&null!=t.minItems){if(!Number.isInteger(t.minItems)||t.minItems<0)throw new Error("'minItems' must be a non-negative integer.");if(e.length<t.minItems)return!1}if(t.hasOwnProperty("uniqueItems")&&null!=t.uniqueItems&&t.uniqueItems){var r=new Set(e);if(e.length!==r.size)return!1}if(Array.isArray(t.items))return this.validateItemsList(e,t);for(var n=0,o=e;n<o.length;n++){var i=o[n];if(!this.validate(i,t.items))return!1}return!0},e.prototype.validateItemsList=function(e,t){var r=t.items;if(e.length!==r.length)return!1;for(var n=0;n<r.length;n+=1)if(!this.validate(e[n],r[n]))return!1;return!0},e.prototype.validateString=function(e,t){if("string"!=typeof e)return!1;if(t.hasOwnProperty("maxLength")&&null!=t.maxLength){if(!Number.isInteger(t.maxLength)||t.maxLength<0)throw new Error("'maxLength' must be a non-negative integer.");if(e.length>t.maxLength)return!1}if(t.hasOwnProperty("minLength")&&null!=t.minLength){if(!Number.isInteger(t.minLength)||t.minLength<0)throw new Error("'minLength' must be a non-negative integer.");if(e.length<t.minLength)return!1}if(t.hasOwnProperty("pattern")&&null!=t.pattern){if(!new RegExp(t.pattern).test(e))return!1}return!0},e.prototype.validateNumber=function(e,t){if("number"!=typeof e)return!1;if("integer"===t.type&&!Number.isInteger(e))return!1;if(t.hasOwnProperty("multipleOf")&&null!=t.multipleOf){if(t.multipleOf<=0)throw new Error("'multipleOf' must be a number strictly greater than 0.");if(!Number.isInteger(e/t.multipleOf))return!1}return!(t.hasOwnProperty("maximum")&&null!=t.maximum&&e>t.maximum)&&(!(t.hasOwnProperty("exclusiveMaximum")&&null!=t.exclusiveMaximum&&e>=t.exclusiveMaximum)&&(!(t.hasOwnProperty("minimum")&&null!=t.minimum&&e<t.minimum)&&!(t.hasOwnProperty("exclusiveMinimum")&&null!=t.exclusiveMinimum&&e<=t.exclusiveMinimum)))},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),f=function(){function e(e,t){this.database=e,this.jsonValidator=t,this.getItemOptionsDefault={schema:null}}return e.prototype.getItem=function(e,t){var r=this;return void 0===t&&(t=this.getItemOptionsDefault),this.database.getItem(e).pipe(o.mergeMap(function(e){if(t.schema&&null!==e){var o=!0;try{o=r.jsonValidator.validate(e,t.schema)}catch(e){return n.throwError(e)}if(!o)return n.throwError(new Error("JSON invalid"))}return n.of(e)}))},e.prototype.setItem=function(e,t){return this.database.setItem(e,t)},e.prototype.removeItem=function(e){return this.database.removeItem(e)},e.prototype.clear=function(){return this.database.clear()},e.prototype.setItemSubscribe=function(e,t){this.setItem(e,t).subscribe(function(){},function(){})},e.prototype.removeItemSubscribe=function(e){this.removeItem(e).subscribe(function(){},function(){})},e.prototype.clearSubscribe=function(){this.clear().subscribe(function(){},function(){})},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:p},{type:l}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(p),t.inject(l))},token:e,providedIn:"root"}),e}();e.LocalDatabase=p,e.IndexedDBDatabase=u,e.LocalStorageDatabase=s,e.MockLocalDatabase=c,e.JSONValidator=l,e.LocalStorage=f,e.localStorageProviders=function(e){return[e.prefix?{provide:a,useValue:e.prefix}:[]]},e.LOCAL_STORAGE_PREFIX=a,e.ɵa=i,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common","rxjs","rxjs/operators"],t):t((e.ngxPWA=e.ngxPWA||{},e.ngxPWA.localStorage=e.ngxPWA.localStorage||{}),e.ng.core,e.ng.common,e.Rx,e.Rx.operators)}(this,function(e,t,r,n,o){"use strict";function i(e,t){return r.isPlatformBrowser(e)&&"indexedDB"in window&&void 0!==indexedDB&&null!==indexedDB?new u(t):r.isPlatformBrowser(e)&&"localStorage"in window&&void 0!==localStorage&&null!==localStorage?new s(t):new c}var a=new t.InjectionToken("localStoragePrefix",{providedIn:"root",factory:function(){return""}}),u=function(){function e(e){void 0===e&&(e=null),this.prefix=e,this.dbName="ngStorage",this.objectStoreName="localStorage",this.keyPath="key",this.dataPath="value",e&&(this.dbName=e+"_"+this.dbName),this.database=new n.ReplaySubject,this.connect()}return e.prototype.getItem=function(e){var t=this;return this.transaction().pipe(o.map(function(t){return t.get(e)}),o.mergeMap(function(e){var r=n.fromEvent(e,"success").pipe(o.map(function(e){return e.target.result}),o.map(function(e){return e&&t.dataPath in e?e[t.dataPath]:null}));return n.race(r,t.toErrorObservable(e,"getter")).pipe(o.first())}),o.first())},e.prototype.setItem=function(e,t){var r=this;return null==t?n.of(!0):this.getItem(e).pipe(o.map(function(e){return null==e?"add":"put"}),o.mergeMap(function(i){return r.transaction("readwrite").pipe(o.mergeMap(function(a){var u;switch(i){case"add":u=a.add((s={},s[r.dataPath]=t,s),e);break;case"put":default:u=a.put((c={},c[r.dataPath]=t,c),e)}return n.race(r.toSuccessObservable(u),r.toErrorObservable(u,"setter")).pipe(o.first());var s,c}))}),o.first())},e.prototype.removeItem=function(e){var t=this;return this.getItem(e).pipe(o.mergeMap(function(r){return null!=r?t.transaction("readwrite").pipe(o.mergeMap(function(r){var i=r.delete(e);return n.race(t.toSuccessObservable(i),t.toErrorObservable(i,"remover")).pipe(o.first())})):n.of(!0)}),o.first())},e.prototype.clear=function(){var e=this;return this.transaction("readwrite").pipe(o.mergeMap(function(t){var r=t.clear();return n.race(e.toSuccessObservable(r),e.toErrorObservable(r,"clearer")).pipe(o.first())}),o.first())},e.prototype.connect=function(){var e=this,t=indexedDB.open(this.dbName);n.fromEvent(t,"upgradeneeded").pipe(o.first()).subscribe(function(t){var r=t.target.result;r.objectStoreNames.contains(e.objectStoreName)||r.createObjectStore(e.objectStoreName)});var r=n.fromEvent(t,"success");n.race(r,this.toErrorObservable(t,"connection")).pipe(o.first()).subscribe(function(t){e.database.next(t.target.result)},function(t){e.database.error(t)})},e.prototype.transaction=function(e){var t=this;return void 0===e&&(e="readonly"),this.database.pipe(o.map(function(r){return r.transaction([t.objectStoreName],e).objectStore(t.objectStoreName)}))},e.prototype.toSuccessObservable=function(e){return n.fromEvent(e,"success").pipe(o.map(function(){return!0}))},e.prototype.toErrorObservable=function(e,t){return void 0===t&&(t=""),n.fromEvent(e,"error").pipe(o.mergeMap(function(r){return n.throwError(new Error("IndexedDB "+t+" issue : "+e.error.message+"."))}))},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[a]}]}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(a,8))},token:e,providedIn:"root"}),e}(),s=function(){function e(e){void 0===e&&(e=null),this.userPrefix=e,this.prefix="",e&&(this.prefix=e+"_")}return e.prototype.getItem=function(e){var t=localStorage.getItem(""+this.prefix+e),r=null;if(null!=t)try{r=JSON.parse(t)}catch(e){return n.throwError(new Error("Invalid data in localStorage."))}return n.of(r)},e.prototype.setItem=function(e,t){return localStorage.setItem(""+this.prefix+e,JSON.stringify(t)),n.of(!0)},e.prototype.removeItem=function(e){return localStorage.removeItem(""+this.prefix+e),n.of(!0)},e.prototype.clear=function(){return localStorage.clear(),n.of(!0)},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[a]}]}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(a,8))},token:e,providedIn:"root"}),e}(),c=function(){function e(){this.localStorage=new Map}return e.prototype.getItem=function(e){var t=this.localStorage.get(e);return n.of(void 0!==t?t:null)},e.prototype.setItem=function(e,t){return this.localStorage.set(e,t),n.of(!0)},e.prototype.removeItem=function(e){return this.localStorage.delete(e),n.of(!0)},e.prototype.clear=function(){return this.localStorage.clear(),n.of(!0)},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),p=function(){function e(){}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root",useFactory:i,deps:[t.PLATFORM_ID,[new t.Optional,a]]}]}],e.ngInjectableDef=t.defineInjectable({factory:function(){return i(t.inject(t.PLATFORM_ID),t.inject(a,8))},token:e,providedIn:"root"}),e}(),l=function(){function e(){}return e.prototype.validate=function(e,t){if(!((t.hasOwnProperty("const")&&void 0!==t.const||t.hasOwnProperty("enum")&&null!=t.enum||t.hasOwnProperty("type")&&null!=t.type)&&"array"!==t.type&&"object"!==t.type||t.hasOwnProperty("properties")&&null!=t.properties||t.hasOwnProperty("items")&&null!=t.items))throw new Error("Each value must have a 'type' or 'properties' or 'items' or 'const' or 'enum', to enforce strict types.");return(!t.hasOwnProperty("const")||void 0===t.const||e===t.const)&&(!!this.validateEnum(e,t)&&(!!this.validateType(e,t)&&(!!this.validateItems(e,t)&&(!!this.validateProperties(e,t)&&!!this.validateRequired(e,t)))))},e.prototype.isObjectNotNull=function(e){return null!==e&&"object"==typeof e},e.prototype.validateProperties=function(e,t){if(!t.hasOwnProperty("properties")||null==t.properties)return!0;if(!this.isObjectNotNull(e))return!1;if(Object.keys(t.properties).length!==Object.keys(e).length)return!1;for(var r in t.properties)if(t.properties.hasOwnProperty(r)&&e.hasOwnProperty(r)&&!this.validate(e[r],t.properties[r]))return!1;return!0},e.prototype.validateRequired=function(e,t){if(!t.hasOwnProperty("required")||null==t.required)return!0;if(!this.isObjectNotNull(e))return!1;for(var r=0,n=t.required;r<n.length;r++){var o=n[r];if(!t.properties||!t.properties.hasOwnProperty(o))throw new Error("'required' properties must be described in 'properties' too.");if(!e.hasOwnProperty(o))return!1}return!0},e.prototype.validateEnum=function(e,t){return!t.hasOwnProperty("enum")||null==t.enum||-1!==t.enum.indexOf(e)},e.prototype.validateType=function(e,t){if(!t.hasOwnProperty("type")||null==t.type)return!0;switch(t.type){case"null":return null===e;case"string":return this.validateString(e,t);case"number":case"integer":return this.validateNumber(e,t);case"boolean":return"boolean"==typeof e;case"object":return"object"==typeof e;case"array":return Array.isArray(e)}},e.prototype.validateItems=function(e,t){if(!t.hasOwnProperty("items")||null==t.items)return!0;if(!Array.isArray(e))return!1;if(t.hasOwnProperty("maxItems")&&null!=t.maxItems){if(!Number.isInteger(t.maxItems)||t.maxItems<0)throw new Error("'maxItems' must be a non-negative integer.");if(e.length>t.maxItems)return!1}if(t.hasOwnProperty("minItems")&&null!=t.minItems){if(!Number.isInteger(t.minItems)||t.minItems<0)throw new Error("'minItems' must be a non-negative integer.");if(e.length<t.minItems)return!1}if(t.hasOwnProperty("uniqueItems")&&null!=t.uniqueItems&&t.uniqueItems){var r=new Set(e);if(e.length!==r.size)return!1}if(Array.isArray(t.items))return this.validateItemsList(e,t);for(var n=0,o=e;n<o.length;n++){var i=o[n];if(!this.validate(i,t.items))return!1}return!0},e.prototype.validateItemsList=function(e,t){var r=t.items;if(e.length!==r.length)return!1;for(var n=0;n<r.length;n+=1)if(!this.validate(e[n],r[n]))return!1;return!0},e.prototype.validateString=function(e,t){if("string"!=typeof e)return!1;if(t.hasOwnProperty("maxLength")&&null!=t.maxLength){if(!Number.isInteger(t.maxLength)||t.maxLength<0)throw new Error("'maxLength' must be a non-negative integer.");if(e.length>t.maxLength)return!1}if(t.hasOwnProperty("minLength")&&null!=t.minLength){if(!Number.isInteger(t.minLength)||t.minLength<0)throw new Error("'minLength' must be a non-negative integer.");if(e.length<t.minLength)return!1}if(t.hasOwnProperty("pattern")&&null!=t.pattern){if(!new RegExp(t.pattern).test(e))return!1}return!0},e.prototype.validateNumber=function(e,t){if("number"!=typeof e)return!1;if("integer"===t.type&&!Number.isInteger(e))return!1;if(t.hasOwnProperty("multipleOf")&&null!=t.multipleOf){if(t.multipleOf<=0)throw new Error("'multipleOf' must be a number strictly greater than 0.");if(!Number.isInteger(e/t.multipleOf))return!1}return!(t.hasOwnProperty("maximum")&&null!=t.maximum&&e>t.maximum)&&(!(t.hasOwnProperty("exclusiveMaximum")&&null!=t.exclusiveMaximum&&e>=t.exclusiveMaximum)&&(!(t.hasOwnProperty("minimum")&&null!=t.minimum&&e<t.minimum)&&!(t.hasOwnProperty("exclusiveMinimum")&&null!=t.exclusiveMinimum&&e<=t.exclusiveMinimum)))},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),f=function(){function e(e,t){this.database=e,this.jsonValidator=t,this.getItemOptionsDefault={schema:null}}return e.prototype.getItem=function(e,t){var r=this;return void 0===t&&(t=this.getItemOptionsDefault),this.database.getItem(e).pipe(o.mergeMap(function(e){if(t.schema&&null!==e){var o=!0;try{o=r.jsonValidator.validate(e,t.schema)}catch(e){return n.throwError(e)}if(!o)return n.throwError(new Error("JSON invalid"))}return n.of(e)}))},e.prototype.setItem=function(e,t){return this.database.setItem(e,t)},e.prototype.removeItem=function(e){return this.database.removeItem(e)},e.prototype.clear=function(){return this.database.clear()},e.prototype.setItemSubscribe=function(e,t){this.setItem(e,t).subscribe(function(){},function(){})},e.prototype.removeItemSubscribe=function(e){this.removeItem(e).subscribe(function(){},function(){})},e.prototype.clearSubscribe=function(){this.clear().subscribe(function(){},function(){})},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:p},{type:l}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(p),t.inject(l))},token:e,providedIn:"root"}),e}();e.LocalDatabase=p,e.IndexedDBDatabase=u,e.LocalStorageDatabase=s,e.MockLocalDatabase=c,e.JSONValidator=l,e.LocalStorage=f,e.localStorageProviders=function(e){return[e.prefix?{provide:a,useValue:e.prefix}:[]]},e.LOCAL_STORAGE_PREFIX=a,e.ɵa=i,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=local-storage.umd.min.js.map |
@@ -56,5 +56,2 @@ import { Inject, Injectable, InjectionToken, Optional, PLATFORM_ID, defineInjectable, inject } from '@angular/core'; | ||
} | ||
if (prefix) { | ||
this.dbName = `${prefix}_${this.dbName}`; | ||
} | ||
/* Creating the RxJS ReplaySubject */ | ||
@@ -61,0 +58,0 @@ this.database = new ReplaySubject(); |
@@ -56,5 +56,2 @@ import { Inject, Injectable, InjectionToken, Optional, PLATFORM_ID, defineInjectable, inject } from '@angular/core'; | ||
} | ||
if (prefix) { | ||
this.dbName = prefix + "_" + this.dbName; | ||
} | ||
/* Creating the RxJS ReplaySubject */ | ||
@@ -61,0 +58,0 @@ this.database = new ReplaySubject(); |
{ | ||
"name": "@ngx-pwa/local-storage", | ||
"version": "6.0.0-rc.0", | ||
"version": "6.0.0-rc.1", | ||
"description": "Efficient local storage module for Angular apps and PWA: simple API based on native localStorage API, but internally stored via the asynchronous IndexedDB API for performance, and wrapped in RxJS observables to be homogeneous with other Angular modules.", | ||
@@ -65,3 +65,3 @@ "main": "./bundles/local-storage.umd.js", | ||
"reinstall": "rimraf node_modules && npm install", | ||
"publish": "npm publish dist --tag rc --access public" | ||
"publish": "npm publish dist --access public" | ||
}, | ||
@@ -68,0 +68,0 @@ "dependencies": {}, |
@@ -48,3 +48,3 @@ # Async local storage for Angular | ||
# For Angular 6: | ||
npm install @ngx-pwa/local-storage@6 | ||
npm install @ngx-pwa/local-storage@latest | ||
@@ -58,3 +58,3 @@ # For Angular 5: | ||
Then, **for *versions 4 & 5 only*, include the `LocalStorageModule`** in your app root module (just once, do NOT re-import it in your submodules). Since *version 6*, this step is no longer required and `LocalStorageModule` is removed. | ||
Then, **for *versions 4 & 5 only*, include the `LocalStorageModule`** in your app root module (just once, do NOT re-import it in your submodules). **Since *version 6*, this step is no longer required and `LocalStorageModule` is *removed*.** | ||
@@ -61,0 +61,0 @@ ```typescript |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
325408
3369