Socket
Socket
Sign inDemoInstall

@ngx-pwa/local-storage

Package Overview
Dependencies
5
Maintainers
1
Versions
125
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.2 to 9.0.3

2

bundles/ngx-pwa-local-storage.umd.min.js

@@ -15,3 +15,3 @@ !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("@ngx-pwa/local-storage",["exports","@angular/core","@angular/common","rxjs","rxjs/operators"],t):t(((e=e||self)["ngx-pwa"]=e["ngx-pwa"]||{},e["ngx-pwa"]["local-storage"]={}),e.ng.core,e.ng.common,e.rxjs,e.rxjs.operators)}(this,(function(e,t,r,n,o){"use strict";

and limitations under the License.
***************************************************************************** */var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function a(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function u(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t){return function(r,n){t(r,n,e)}}function c(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.message="indexedDB is not working",t}return a(t,e),t}(Error),f="The storage is currently localStorage,\nwhere data must be serialized, and the provided data can't be serialized.",l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=f,t}return a(t,e),t}(Error),d=new t.InjectionToken("localStoragePrefix",{providedIn:"root",factory:function(){return""}}),y=new t.InjectionToken("localStorageIDBDBName",{providedIn:"root",factory:function(){return"ngStorage"}}),h=new t.InjectionToken("localStorageIDBDBVersion",{providedIn:"root",factory:function(){return 1}}),v=new t.InjectionToken("localStorageIDBStoreName",{providedIn:"root",factory:function(){return"localStorage"}}),g=new t.InjectionToken("localStorageIDBWrap",{providedIn:"root",factory:function(){return!0}}),m=function(){function e(e,t,r,o){void 0===e&&(e="ngStorage"),void 0===t&&(t="localStorage"),void 0===r&&(r=1),void 0===o&&(o=!0),this.database=new n.ReplaySubject(1),this.wrapIndex="value",this.dbName=e,this.storeName=t,this.dbVersion=r,this.noWrap=o,this.connect()}return Object.defineProperty(e.prototype,"backingStore",{get:function(){return{database:this.dbName,store:this.storeName,version:this.dbVersion}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.transaction("readonly").pipe(o.mergeMap((function(e){var t=e.store,r=e.events,n=t.count();return r.pipe(o.map((function(){return n.result})))})),o.first())},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var t=this;return this.transaction("readonly").pipe(o.mergeMap((function(r){var n=r.store,i=r.events,a=n.get(e);return i.pipe(o.map((function(){if(void 0!==a.result&&null!==a.result)return!t.noWrap&&"object"==typeof a.result&&t.wrapIndex in a.result&&void 0!==a.result[t.wrapIndex]&&null!==a.result[t.wrapIndex]?a.result[t.wrapIndex]:a.result})))})),o.first())},e.prototype.set=function(e,t){var r=this;return void 0===t?this.delete(e):this.transaction("readwrite").pipe(o.mergeMap((function(n){var i,a=n.store,u=n.events,s=r.noWrap?t:((i={})[r.wrapIndex]=t,i);return a.put(s,e),u.pipe(o.mapTo(void 0))})),o.first())},e.prototype.delete=function(e){return this.transaction("readwrite").pipe(o.mergeMap((function(t){var r=t.store,n=t.events;return r.delete(e),n.pipe(o.mapTo(void 0))})),o.first())},e.prototype.clear=function(){return this.transaction("readwrite").pipe(o.mergeMap((function(e){var t=e.store,r=e.events;return t.clear(),r.pipe(o.mapTo(void 0))})),o.first())},e.prototype.keys=function(){var e=this;return this.transaction("readonly").pipe(o.first(),o.mergeMap((function(t){var r=t.store,i="openKeyCursor"in r?r.openKeyCursor():r.openCursor(),a=n.fromEvent(i,"success").pipe(o.takeWhile((function(){return null!==i.result})),o.map((function(){return i.result.key.toString()})),o.tap((function(){i.result.continue()}))),u=e.listenError(i);return n.race([a,u])})))},e.prototype.has=function(e){return this.transaction("readonly").pipe(o.mergeMap((function(t){var r=t.store,n=t.events,i="getKey"in r?r.getKey(e):r.get(e);return n.pipe(o.map((function(){return void 0!==i.result})))})),o.first())},e.prototype.connect=function(){var e,t=this;try{e=indexedDB.open(this.dbName,this.dbVersion)}catch(e){return void this.database.error(new p)}this.createStore(e);var r=n.fromEvent(e,"success"),i=this.listenError(e);n.race([r,i]).pipe(o.first()).subscribe({next:function(){t.database.next(e.result)},error:function(){t.database.error(new p)}})},e.prototype.createStore=function(e){var t=this;n.fromEvent(e,"upgradeneeded").pipe(o.first()).subscribe({next:function(){e.result.objectStoreNames.contains(t.storeName)||e.result.createObjectStore(t.storeName)}})},e.prototype.transaction=function(e){var t=this;return this.database.pipe(o.mergeMap((function(r){var o;try{o=r.transaction([t.storeName],e)}catch(e){return n.throwError(e)}var i=o.objectStore(t.storeName),a=t.listenTransactionEvents(o);return n.of({store:i,events:a})})))},e.prototype.listenError=function(e){return n.fromEvent(e,"error").pipe(o.mergeMap((function(){return n.throwError(e.error)})))},e.prototype.listenTransactionEvents=function(e){var t=n.fromEvent(e,"complete"),r=this.listenError(e);return n.race([t,r])},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[y]}]},{type:void 0,decorators:[{type:t.Inject,args:[v]}]},{type:void 0,decorators:[{type:t.Inject,args:[h]}]},{type:void 0,decorators:[{type:t.Inject,args:[g]}]}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](y),t["ɵɵinject"](v),t["ɵɵinject"](h),t["ɵɵinject"](g))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"}),s(0,t.Inject(y)),s(1,t.Inject(v)),s(2,t.Inject(h)),s(3,t.Inject(g))],e)}(),b=function(){function e(e){void 0===e&&(e=""),this.prefix=e||""}return Object.defineProperty(e.prototype,"size",{get:function(){return n.of(localStorage.length)},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var t,r=localStorage.getItem(this.prefixKey(e));if(null!=r)try{t=JSON.parse(r)}catch(e){return n.throwError(e)}return n.of(t)},e.prototype.set=function(e,t){var r=null,o=Object.getPrototypeOf(t);if("object"==typeof t&&null!==t&&!Array.isArray(t)&&o!==Object.prototype&&null!==o)return n.throwError(new l);try{r=JSON.stringify(t)}catch(e){return n.throwError(e)}try{localStorage.setItem(this.prefixKey(e),r)}catch(e){return n.throwError(e)}return n.of(void 0)},e.prototype.delete=function(e){return localStorage.removeItem(this.prefixKey(e)),n.of(void 0)},e.prototype.clear=function(){return localStorage.clear(),n.of(void 0)},e.prototype.keys=function(){var e=this;return new n.Observable((function(t){for(var r=0;r<localStorage.length;r+=1)t.next(e.getUnprefixedKey(r));t.complete()})).pipe(o.observeOn(n.asyncScheduler))},e.prototype.has=function(e){for(var t=0;t<localStorage.length;t+=1)if(e===this.getUnprefixedKey(t))return n.of(!0);return n.of(!1)},e.prototype.getUnprefixedKey=function(e){var t=localStorage.key(e);return null!==t?this.prefix?t.substr(this.prefix.length):t:null},e.prototype.prefixKey=function(e){return""+this.prefix+e},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[d]}]}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](d))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"}),s(0,t.Inject(d))],e)}(),I=function(){function e(){this.memoryStorage=new Map}return Object.defineProperty(e.prototype,"size",{get:function(){return n.of(this.memoryStorage.size)},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var t=this.memoryStorage.get(e);return n.of(t)},e.prototype.set=function(e,t){return this.memoryStorage.set(e,t),n.of(void 0)},e.prototype.delete=function(e){return this.memoryStorage.delete(e),n.of(void 0)},e.prototype.clear=function(){return this.memoryStorage.clear(),n.of(void 0)},e.prototype.keys=function(){return n.from(this.memoryStorage.keys())},e.prototype.has=function(e){return n.of(this.memoryStorage.has(e))},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"})],e)}();function j(e,t,n,o,i,a){try{if(r.isPlatformBrowser(e)&&void 0!==indexedDB&&null!==indexedDB&&"open"in indexedDB)return new m(n,o,i,a);if(r.isPlatformBrowser(e)&&void 0!==localStorage&&null!==localStorage&&"getItem"in localStorage)return new b(t)}catch(e){}return new I}var x=function(){function e(){}return e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return j(t["ɵɵinject"](t.PLATFORM_ID),t["ɵɵinject"](d),t["ɵɵinject"](y),t["ɵɵinject"](v),t["ɵɵinject"](h),t["ɵɵinject"](g))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root",useFactory:j,deps:[t.PLATFORM_ID,d,y,v,h,g]})],e)}(),w="Data stored is not valid against the provided JSON schema.\nCheck your JSON schema, otherwise it means data has been corrupted.",S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=w,t}return a(t,e),t}(Error),B=function(){function e(){}return e.prototype.validate=function(e,t){switch(t.type){case"string":return this.validateString(e,t);case"number":case"integer":return this.validateNumber(e,t);case"boolean":return this.validateBoolean(e,t);case"array":return this.validateArray(e,t);case"object":return this.validateObject(e,t)}},e.prototype.validateString=function(e,t){if("string"!=typeof e)return!1;if(!this.validateConst(e,t))return!1;if(!this.validateEnum(e,t))return!1;if(void 0!==t.maxLength&&e.length>t.maxLength)return!1;if(void 0!==t.minLength&&e.length<t.minLength)return!1;if(t.pattern){var r=null;try{r=new RegExp(t.pattern)}catch(e){}if(r&&!r.test(e))return!1}return!0},e.prototype.validateNumber=function(e,t){return"number"==typeof e&&(!("integer"===t.type&&!Number.isInteger(e))&&(!!this.validateConst(e,t)&&(!!this.validateEnum(e,t)&&(!(t.multipleOf&&!Number.isInteger(e/t.multipleOf))&&(!(void 0!==t.maximum&&e>t.maximum)&&(!(void 0!==t.exclusiveMaximum&&e>=t.exclusiveMaximum)&&(!(void 0!==t.minimum&&e<t.minimum)&&!(void 0!==t.exclusiveMinimum&&e<=t.exclusiveMinimum))))))))},e.prototype.validateBoolean=function(e,t){return"boolean"==typeof e&&!!this.validateConst(e,t)},e.prototype.validateArray=function(e,t){var r,n;if(!Array.isArray(e))return!1;if(void 0!==t.maxItems&&e.length>t.maxItems)return!1;if(void 0!==t.minItems&&e.length<t.minItems)return!1;if(t.uniqueItems){var o=new Set(e);if(e.length!==o.size)return!1}if(Array.isArray(t.items))return this.validateTuple(e,t.items);try{for(var i=c(e),a=i.next();!a.done;a=i.next()){var u=a.value;if(!this.validate(u,t.items))return!1}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0},e.prototype.validateTuple=function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<t.length;r+=1)if(!this.validate(e[r],t[r]))return!1;return!0},e.prototype.validateObject=function(e,t){var r,n;if("object"!=typeof e||null===e)return!1;if(Object.keys(t.properties).length<Object.keys(e).length)return!1;if(t.required)try{for(var o=c(t.required),i=o.next();!i.done;i=o.next()){var a=i.value;if(!e.hasOwnProperty(a))return!1}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}for(var u in t.properties)if(t.properties.hasOwnProperty(u)&&e.hasOwnProperty(u)&&!this.validate(e[u],t.properties[u]))return!1;return!0},e.prototype.validateConst=function(e,t){return!t.const||e===t.const},e.prototype.validateEnum=function(e,t){return!t.enum||t.enum.includes(e)},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"})],e)}(),O=function(){function e(e,t,r){void 0===t&&(t=new B),void 0===r&&(r=""),this.database=e,this.jsonValidator=t,this.LSPrefix=r,this.notifiers=new Map}return Object.defineProperty(e.prototype,"size",{get:function(){var e=this;return this.database.size.pipe(this.catchIDBBroken((function(){return e.database.size})))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"backingEngine",{get:function(){return this.database instanceof m?"indexedDB":this.database instanceof b?"localStorage":this.database instanceof I?"memory":"unknown"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"backingStore",{get:function(){return this.database instanceof m?this.database.backingStore:{database:"",store:"",version:0}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fallbackBackingStore",{get:function(){return this.database instanceof b?{prefix:this.database.prefix}:{prefix:""}},enumerable:!0,configurable:!0}),e.prototype.get=function(e,t){var r=this;return this.database.get(e).pipe(this.catchIDBBroken((function(){return r.database.get(e)})),o.mergeMap((function(e){return null==e?n.of(void 0):t?r.jsonValidator.validate(e,t)?n.of(e):n.throwError(new S):n.of(e)})))},e.prototype.set=function(e,t,r){var i=this;return null==t?this.delete(e):r&&!this.jsonValidator.validate(t,r)?n.throwError(new S):this.database.set(e,t).pipe(this.catchIDBBroken((function(){return i.database.set(e,t)})),o.tap((function(){i.notify(e,t)})))},e.prototype.delete=function(e){var t=this;return this.database.delete(e).pipe(this.catchIDBBroken((function(){return t.database.delete(e)})),o.tap((function(){t.notify(e,void 0)})))},e.prototype.clear=function(){var e=this;return this.database.clear().pipe(this.catchIDBBroken((function(){return e.database.clear()})),o.tap((function(){var t,r;try{for(var n=c(e.notifiers.keys()),o=n.next();!o.done;o=n.next()){var i=o.value;e.notify(i,void 0)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}})))},e.prototype.keys=function(){var e=this;return this.database.keys().pipe(this.catchIDBBroken((function(){return e.database.keys()})))},e.prototype.has=function(e){var t=this;return this.database.has(e).pipe(this.catchIDBBroken((function(){return t.database.has(e)})))},e.prototype.watch=function(e,t){var r=this.notifiers.get(e);return r||(r=new n.ReplaySubject(1),this.notifiers.set(e,r),this.get(e,t).subscribe({next:function(e){return r.next(e)},error:function(e){return r.error(e)}})),r.asObservable()},e.prototype.notify=function(e,t){var r=this.notifiers.get(e);r&&r.next(t)},e.prototype.catchIDBBroken=function(e){var t=this;return o.catchError((function(r){if(null!=r&&"indexedDB is not working"===r.message){try{"getItem"in localStorage?t.database=new b(t.LSPrefix):t.database=new I}catch(e){t.database=new I}return e()}return n.throwError(r)}))},e.ctorParameters=function(){return[{type:x},{type:B},{type:void 0,decorators:[{type:t.Inject,args:[d]}]}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](x),t["ɵɵinject"](B),t["ɵɵinject"](d))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"}),s(2,t.Inject(d))],e)}(),k=function(){function e(e){this.storageMap=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this.storageMap.size},enumerable:!0,configurable:!0}),e.prototype.getItem=function(e,t){if(t){var r="schema"in t?t.schema:t;return this.storageMap.get(e,r).pipe(o.map((function(e){return void 0!==e?e:null})))}return this.storageMap.get(e).pipe(o.map((function(e){return void 0!==e?e:null})))},e.prototype.setItem=function(e,t,r){return this.storageMap.set(e,t,r).pipe(o.mapTo(!0))},e.prototype.removeItem=function(e){return this.storageMap.delete(e).pipe(o.mapTo(!0))},e.prototype.clear=function(){return this.storageMap.clear().pipe(o.mapTo(!0))},e.ctorParameters=function(){return[{type:O}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](O))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"})],e)}(),D=function(){function e(){}var r;return r=e,e.forRoot=function(e){return{ngModule:r,providers:[e.LSPrefix?{provide:d,useValue:e.LSPrefix}:[],e.IDBDBName?{provide:y,useValue:e.IDBDBName}:[],e.IDBStoreName?{provide:v,useValue:e.IDBStoreName}:[],e.IDBDBVersion?{provide:h,useValue:e.IDBDBVersion}:[],!1===e.IDBNoWrap?{provide:g,useValue:e.IDBNoWrap}:[]]}},e=r=u([t.NgModule()],e)}();e.JSONValidator=B,e.LocalDatabase=x,e.LocalStorage=k,e.SERIALIZATION_ERROR=f,e.SerializationError=l,e.StorageMap=O,e.StorageModule=D,e.VALIDATION_ERROR=w,e.ValidationError=S,e.ɵa=d,e.ɵb=y,e.ɵc=h,e.ɵd=v,e.ɵe=g,Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function a(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function u(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t){return function(r,n){t(r,n,e)}}function c(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.message="indexedDB is not working",t}return a(t,e),t}(Error),f="The storage is currently localStorage,\nwhere data must be serialized, and the provided data can't be serialized.",l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=f,t}return a(t,e),t}(Error),d=new t.InjectionToken("localStoragePrefix",{providedIn:"root",factory:function(){return""}}),y=new t.InjectionToken("localStorageIDBDBName",{providedIn:"root",factory:function(){return"ngStorage"}}),h=new t.InjectionToken("localStorageIDBDBVersion",{providedIn:"root",factory:function(){return 1}}),v=new t.InjectionToken("localStorageIDBStoreName",{providedIn:"root",factory:function(){return"localStorage"}}),g=new t.InjectionToken("localStorageIDBWrap",{providedIn:"root",factory:function(){return!0}}),m=function(){function e(e,t,r,o){void 0===e&&(e="ngStorage"),void 0===t&&(t="localStorage"),void 0===r&&(r=1),void 0===o&&(o=!0),this.database=new n.ReplaySubject(1),this.wrapIndex="value",this.dbName=e,this.storeName=t,this.dbVersion=r,this.noWrap=o,this.connect()}return Object.defineProperty(e.prototype,"backingStore",{get:function(){return{database:this.dbName,store:this.storeName,version:this.dbVersion}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.transaction("readonly").pipe(o.mergeMap((function(e){var t=e.store,r=e.events,n=t.count();return r.pipe(o.map((function(){return n.result})))})),o.first())},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var t=this;return this.transaction("readonly").pipe(o.mergeMap((function(r){var n=r.store,i=r.events,a=n.get(e);return i.pipe(o.map((function(){if(void 0!==a.result&&null!==a.result)return!t.noWrap&&"object"==typeof a.result&&t.wrapIndex in a.result&&void 0!==a.result[t.wrapIndex]&&null!==a.result[t.wrapIndex]?a.result[t.wrapIndex]:a.result})))})),o.first())},e.prototype.set=function(e,t){var r=this;return void 0===t?this.delete(e):this.transaction("readwrite").pipe(o.mergeMap((function(n){var i,a=n.store,u=n.events,s=r.noWrap?t:((i={})[r.wrapIndex]=t,i);return a.put(s,e),u.pipe(o.mapTo(void 0))})),o.first())},e.prototype.delete=function(e){return this.transaction("readwrite").pipe(o.mergeMap((function(t){var r=t.store,n=t.events;return r.delete(e),n.pipe(o.mapTo(void 0))})),o.first())},e.prototype.clear=function(){return this.transaction("readwrite").pipe(o.mergeMap((function(e){var t=e.store,r=e.events;return t.clear(),r.pipe(o.mapTo(void 0))})),o.first())},e.prototype.keys=function(){var e=this;return this.transaction("readonly").pipe(o.first(),o.mergeMap((function(t){var r=t.store,i="openKeyCursor"in r?r.openKeyCursor():r.openCursor(),a=n.fromEvent(i,"success").pipe(o.takeWhile((function(){return null!==i.result})),o.map((function(){return i.result.key.toString()})),o.tap((function(){i.result.continue()}))),u=e.listenError(i);return n.race([a,u])})))},e.prototype.has=function(e){return this.transaction("readonly").pipe(o.mergeMap((function(t){var r=t.store,n=t.events,i="getKey"in r?r.getKey(e):r.get(e);return n.pipe(o.map((function(){return void 0!==i.result})))})),o.first())},e.prototype.connect=function(){var e,t=this;try{e=indexedDB.open(this.dbName,this.dbVersion)}catch(e){return void this.database.error(new p)}this.createStore(e);var r=n.fromEvent(e,"success"),i=this.listenError(e);n.race([r,i]).pipe(o.first()).subscribe({next:function(){t.database.next(e.result)},error:function(){t.database.error(new p)}})},e.prototype.createStore=function(e){var t=this;n.fromEvent(e,"upgradeneeded").pipe(o.first()).subscribe({next:function(){e.result.objectStoreNames.contains(t.storeName)||e.result.createObjectStore(t.storeName)}})},e.prototype.transaction=function(e){var t=this;return this.database.pipe(o.mergeMap((function(r){var o;try{o=r.transaction([t.storeName],e)}catch(e){return n.throwError(e)}var i=o.objectStore(t.storeName),a=t.listenTransactionEvents(o);return n.of({store:i,events:a})})))},e.prototype.listenError=function(e){return n.fromEvent(e,"error").pipe(o.mergeMap((function(){return n.throwError(e.error)})))},e.prototype.listenTransactionEvents=function(e){var t=n.fromEvent(e,"complete"),r=this.listenError(e);return n.race([t,r])},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[y]}]},{type:void 0,decorators:[{type:t.Inject,args:[v]}]},{type:void 0,decorators:[{type:t.Inject,args:[h]}]},{type:void 0,decorators:[{type:t.Inject,args:[g]}]}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](y),t["ɵɵinject"](v),t["ɵɵinject"](h),t["ɵɵinject"](g))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"}),s(0,t.Inject(y)),s(1,t.Inject(v)),s(2,t.Inject(h)),s(3,t.Inject(g))],e)}(),b=function(){function e(e){void 0===e&&(e=""),this.prefix=e||""}return Object.defineProperty(e.prototype,"size",{get:function(){return n.of(localStorage.length)},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var t,r=localStorage.getItem(this.prefixKey(e));if(null!=r)try{t=JSON.parse(r)}catch(e){return n.throwError(e)}return n.of(t)},e.prototype.set=function(e,t){var r=null,o=Object.getPrototypeOf(t);if("object"==typeof t&&null!==t&&!Array.isArray(t)&&o!==Object.prototype&&null!==o)return n.throwError(new l);try{r=JSON.stringify(t)}catch(e){return n.throwError(e)}try{localStorage.setItem(this.prefixKey(e),r)}catch(e){return n.throwError(e)}return n.of(void 0)},e.prototype.delete=function(e){return localStorage.removeItem(this.prefixKey(e)),n.of(void 0)},e.prototype.clear=function(){return localStorage.clear(),n.of(void 0)},e.prototype.keys=function(){var e=this;return new n.Observable((function(t){for(var r=0;r<localStorage.length;r+=1)t.next(e.getUnprefixedKey(r));t.complete()})).pipe(o.observeOn(n.asyncScheduler))},e.prototype.has=function(e){for(var t=0;t<localStorage.length;t+=1)if(e===this.getUnprefixedKey(t))return n.of(!0);return n.of(!1)},e.prototype.getUnprefixedKey=function(e){var t=localStorage.key(e);return null!==t?this.prefix?t.substr(this.prefix.length):t:null},e.prototype.prefixKey=function(e){return""+this.prefix+e},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[d]}]}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](d))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"}),s(0,t.Inject(d))],e)}(),I=function(){function e(){this.memoryStorage=new Map}return Object.defineProperty(e.prototype,"size",{get:function(){return n.of(this.memoryStorage.size)},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var t=this.memoryStorage.get(e);return n.of(t)},e.prototype.set=function(e,t){return this.memoryStorage.set(e,t),n.of(void 0)},e.prototype.delete=function(e){return this.memoryStorage.delete(e),n.of(void 0)},e.prototype.clear=function(){return this.memoryStorage.clear(),n.of(void 0)},e.prototype.keys=function(){return n.from(this.memoryStorage.keys())},e.prototype.has=function(e){return n.of(this.memoryStorage.has(e))},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"})],e)}();function j(e,t,n,o,i,a){try{if(r.isPlatformBrowser(e)&&void 0!==indexedDB&&null!==indexedDB&&"open"in indexedDB)return new m(n,o,i,a);if(r.isPlatformBrowser(e)&&void 0!==localStorage&&null!==localStorage&&"getItem"in localStorage)return new b(t)}catch(e){}return new I}var w=function(){function e(){}return e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return j(t["ɵɵinject"](t.PLATFORM_ID),t["ɵɵinject"](d),t["ɵɵinject"](y),t["ɵɵinject"](v),t["ɵɵinject"](h),t["ɵɵinject"](g))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root",useFactory:j,deps:[t.PLATFORM_ID,d,y,v,h,g]})],e)}(),x="Data stored is not valid against the provided JSON schema.\nCheck your JSON schema, otherwise it means data has been corrupted.",S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.message=x,t}return a(t,e),t}(Error),B=function(){function e(){}return e.prototype.validate=function(e,t){switch(t.type){case"string":return this.validateString(e,t);case"number":case"integer":return this.validateNumber(e,t);case"boolean":return this.validateBoolean(e,t);case"array":return this.validateArray(e,t);case"object":return this.validateObject(e,t)}},e.prototype.validateString=function(e,t){if("string"!=typeof e)return!1;if(!this.validateConst(e,t))return!1;if(!this.validateEnum(e,t))return!1;if(void 0!==t.maxLength&&e.length>t.maxLength)return!1;if(void 0!==t.minLength&&e.length<t.minLength)return!1;if(t.pattern){var r=null;try{r=new RegExp(t.pattern)}catch(e){}if(r&&!r.test(e))return!1}return!0},e.prototype.validateNumber=function(e,t){return"number"==typeof e&&(!("integer"===t.type&&!Number.isInteger(e))&&(!!this.validateConst(e,t)&&(!!this.validateEnum(e,t)&&(!(t.multipleOf&&!Number.isInteger(e/t.multipleOf))&&(!(void 0!==t.maximum&&e>t.maximum)&&(!(void 0!==t.exclusiveMaximum&&e>=t.exclusiveMaximum)&&(!(void 0!==t.minimum&&e<t.minimum)&&!(void 0!==t.exclusiveMinimum&&e<=t.exclusiveMinimum))))))))},e.prototype.validateBoolean=function(e,t){return"boolean"==typeof e&&!!this.validateConst(e,t)},e.prototype.validateArray=function(e,t){var r,n;if(!Array.isArray(e))return!1;if(void 0!==t.maxItems&&e.length>t.maxItems)return!1;if(void 0!==t.minItems&&e.length<t.minItems)return!1;if(t.uniqueItems){var o=new Set(e);if(e.length!==o.size)return!1}if(Array.isArray(t.items))return this.validateTuple(e,t.items);try{for(var i=c(e),a=i.next();!a.done;a=i.next()){var u=a.value;if(!this.validate(u,t.items))return!1}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0},e.prototype.validateTuple=function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<t.length;r+=1)if(!this.validate(e[r],t[r]))return!1;return!0},e.prototype.validateObject=function(e,t){var r,n;if("object"!=typeof e||null===e)return!1;if(Object.keys(t.properties).length<Object.keys(e).length)return!1;if(t.required)try{for(var o=c(t.required),i=o.next();!i.done;i=o.next()){var a=i.value;if(!e.hasOwnProperty(a))return!1}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}for(var u in t.properties)if(t.properties.hasOwnProperty(u)&&e.hasOwnProperty(u)&&!this.validate(e[u],t.properties[u]))return!1;return!0},e.prototype.validateConst=function(e,t){return!t.const||e===t.const},e.prototype.validateEnum=function(e,t){return!t.enum||t.enum.includes(e)},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"})],e)}(),O=function(){function e(e,t,r){void 0===t&&(t=new B),void 0===r&&(r=""),this.database=e,this.jsonValidator=t,this.LSPrefix=r,this.notifiers=new Map}return Object.defineProperty(e.prototype,"size",{get:function(){var e=this;return this.database.size.pipe(this.catchIDBBroken((function(){return e.database.size})))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"backingEngine",{get:function(){return this.database instanceof m?"indexedDB":this.database instanceof b?"localStorage":this.database instanceof I?"memory":"unknown"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"backingStore",{get:function(){return this.database instanceof m?this.database.backingStore:{database:"",store:"",version:0}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fallbackBackingStore",{get:function(){return this.database instanceof b?{prefix:this.database.prefix}:{prefix:""}},enumerable:!0,configurable:!0}),e.prototype.get=function(e,t){var r=this;return this.database.get(e).pipe(this.catchIDBBroken((function(){return r.database.get(e)})),o.mergeMap((function(e){return null==e?n.of(void 0):t?r.jsonValidator.validate(e,t)?n.of(e):n.throwError(new S):n.of(e)})))},e.prototype.set=function(e,t,r){var i=this;return null==t?this.delete(e):r&&!this.jsonValidator.validate(t,r)?n.throwError(new S):this.database.set(e,t).pipe(this.catchIDBBroken((function(){return i.database.set(e,t)})),o.tap((function(){i.notify(e,t)})))},e.prototype.delete=function(e){var t=this;return this.database.delete(e).pipe(this.catchIDBBroken((function(){return t.database.delete(e)})),o.tap((function(){t.notify(e,void 0)})))},e.prototype.clear=function(){var e=this;return this.database.clear().pipe(this.catchIDBBroken((function(){return e.database.clear()})),o.tap((function(){var t,r;try{for(var n=c(e.notifiers.keys()),o=n.next();!o.done;o=n.next()){var i=o.value;e.notify(i,void 0)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}})))},e.prototype.keys=function(){var e=this;return this.database.keys().pipe(this.catchIDBBroken((function(){return e.database.keys()})))},e.prototype.has=function(e){var t=this;return this.database.has(e).pipe(this.catchIDBBroken((function(){return t.database.has(e)})))},e.prototype.watch=function(e,t){var r=this.notifiers.get(e);return r||(r=new n.ReplaySubject(1),this.notifiers.set(e,r),this.get(e,t).subscribe({next:function(e){return r.next(e)},error:function(e){return r.error(e)}})),r.asObservable()},e.prototype.notify=function(e,t){var r=this.notifiers.get(e);r&&r.next(t)},e.prototype.catchIDBBroken=function(e){var t=this;return o.catchError((function(r){if(null!=r&&"indexedDB is not working"===r.message){try{"getItem"in localStorage?t.database=new b(t.LSPrefix):t.database=new I}catch(e){t.database=new I}return e()}return n.throwError(r)}))},e.ctorParameters=function(){return[{type:w},{type:B},{type:void 0,decorators:[{type:t.Inject,args:[d]}]}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](w),t["ɵɵinject"](B),t["ɵɵinject"](d))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"}),s(2,t.Inject(d))],e)}(),k=function(){function e(e){this.storageMap=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this.storageMap.size},enumerable:!0,configurable:!0}),e.prototype.getItem=function(e,t){if(t){var r="schema"in t?t.schema:t;return this.storageMap.get(e,r).pipe(o.map((function(e){return void 0!==e?e:null})))}return this.storageMap.get(e).pipe(o.map((function(e){return void 0!==e?e:null})))},e.prototype.setItem=function(e,t,r){return this.storageMap.set(e,t,r).pipe(o.mapTo(!0))},e.prototype.removeItem=function(e){return this.storageMap.delete(e).pipe(o.mapTo(!0))},e.prototype.clear=function(){return this.storageMap.clear().pipe(o.mapTo(!0))},e.ctorParameters=function(){return[{type:O}]},e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e(t["ɵɵinject"](O))},token:e,providedIn:"root"}),e=u([t.Injectable({providedIn:"root"})],e)}(),D=function(){function e(){}var r;return r=e,e.forRoot=function(e){return{ngModule:r,providers:[e.LSPrefix?{provide:d,useValue:e.LSPrefix}:[],e.IDBDBName?{provide:y,useValue:e.IDBDBName}:[],e.IDBStoreName?{provide:v,useValue:e.IDBStoreName}:[],e.IDBDBVersion?{provide:h,useValue:e.IDBDBVersion}:[],!1===e.IDBNoWrap?{provide:g,useValue:e.IDBNoWrap}:[]]}},e=r=u([t.NgModule()],e)}();e.JSONValidator=B,e.LocalDatabase=w,e.LocalStorage=k,e.SERIALIZATION_ERROR=f,e.SerializationError=l,e.StorageMap=O,e.StorageModule=D,e.VALIDATION_ERROR=x,e.ValidationError=S,e.ɵa=d,e.ɵb=y,e.ɵc=h,e.ɵd=v,e.ɵe=g,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-pwa-local-storage.umd.min.js.map
{
"name": "@ngx-pwa/local-storage",
"version": "9.0.2",
"version": "9.0.3",
"funding": {

@@ -8,3 +8,3 @@ "type": "github",

},
"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.",
"description": "Efficient local storage module for Angular: 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.",
"author": "Cyrille Tuzi",

@@ -14,13 +14,9 @@ "license": "MIT",

"angular",
"angular7",
"angular 7",
"angular8",
"angular 8",
"angular9",
"angular 9",
"localstorage",
"local storage",
"storage",
"indexeddb",
"PWA",
"progressive web app"
"angular9",
"angular 9",
"rxjs"
],

@@ -27,0 +23,0 @@ "repository": {

# Async local storage for Angular
Efficient client-side storage module for Angular apps and Progressive Wep Apps (PWA):
Efficient client-side storage module for Angular:
- **simplicity**: based on native `localStorage` API,

@@ -13,14 +13,7 @@ - **perfomance**: internally stored via the asynchronous `indexedDB` API,

What started as a personal project is now,
according to [ngx.tools](https://ngx.tools/#/search?q=local%20storage),
**the 1st Angular library used for client-side storage**,
with about 10 000 downloads [on npm](https://www.npmjs.com/package/@ngx-pwa/local-storage) each week.
What started as a personal project is now one of the most used Angular library
for client-side storage, with more than 10 000 downloads
[on npm](https://www.npmjs.com/package/@ngx-pwa/local-storage) each week.
But I'm still the only maintainer, and everything is done during my free time.
The lib may seem easy to use, but it's a lot of work.
Both client-side storage (with all vendors issues...)
and maintaining a reliable Angular library (up to date with the framework releases),
are difficult topics.
So if your company earns money with projects using this lib,
It's a lot of *free* work. So if your company earns money with projects using this lib,
it would be nice to **consider becoming [a sponsor](https://github.com/sponsors/cyrilletuzi)**.

@@ -31,2 +24,3 @@

- [Angular schematics extension for VS Code](https://marketplace.visualstudio.com/items?itemName=cyrilletuzi.angular-schematics) (GUI for Angular CLI commands)
- [typescript-strictly-typed](https://github.com/cyrilletuzi/typescript-strictly-typed): strict config for TypeScript, ESLint/TSLint and Angular
- Popular [Angular posts on Medium](https://medium.com/@cyrilletuzi)

@@ -110,6 +104,2 @@ - Follow updates of this lib on [Twitter](https://twitter.com/cyrilletuzi)

class StorageMap {
// Read
get(index: string): Observable<unknown> {}
get<T>(index: string, schema: JSONSchema): Observable<T> {}
// Write

@@ -120,2 +110,10 @@ set(index: string, value: any): Observable<undefined> {}

// Read (one-time)
get(index: string): Observable<unknown> {}
get<T>(index: string, schema: JSONSchema): Observable<T> {}
// Observe (version >= 9)
watch(index: string): Observable<unknown> {}
watch<T>(index: string, schema: JSONSchema): Observable<T> {}
// Advanced

@@ -149,6 +147,2 @@ size: Observable<number>;

class LocalStorage {
// Read
getItem(index: string): Observable<unknown> {}
getItem<T>(index: string, schema: JSONSchema): Observable<T> {}
// Write

@@ -159,2 +153,6 @@ setItem(index: string, value: any): Observable<true> {}

// Read (one-time)
getItem(index: string): Observable<unknown> {}
getItem<T>(index: string, schema: JSONSchema): Observable<T> {}
// Advanced

@@ -161,0 +159,0 @@ length: Observable<number>;

import { Tree } from '@angular-devkit/schematics';
export declare const packageName = "@ngx-pwa/local-storage";
export declare const packageVersionLatest = "^9.0.2";
export declare const packageVersionLatest = "^9.0.3";
export declare const packageVersionLTS8 = "^8.2.4";

@@ -5,0 +5,0 @@ export declare const packageVersionLTS7 = "^6.2.5";

@@ -18,3 +18,3 @@ "use strict";

// TODO: Automate this
exports.packageVersionLatest = '^9.0.2';
exports.packageVersionLatest = '^9.0.3';
exports.packageVersionLTS8 = '^8.2.4';

@@ -21,0 +21,0 @@ exports.packageVersionLTS7 = '^6.2.5';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc