Socket
Socket
Sign inDemoInstall

@ngx-pwa/local-storage

Package Overview
Dependencies
6
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.3.0 to 5.3.1

66

bundles/local-storage.umd.js

@@ -107,5 +107,25 @@ (function (global, factory) {

function (key) {
/* Opening a trasaction and requesting the item in local storage */
return this.getItemFromTransaction(key);
};
/**
* Internal method to factorize the getter for getItem and setItem,
* the last one needing to be from a preexisting transaction
* @template T
* @param {?} key The item's key
* @param {?=} transactionParam Optional pre-existing transaction to use for the read request
* @return {?} The item's value if the key exists, null otherwise, wrapped in an RxJS Observable
*/
IndexedDBDatabase.prototype.getItemFromTransaction = /**
* Internal method to factorize the getter for getItem and setItem,
* the last one needing to be from a preexisting transaction
* @template T
* @param {?} key The item's key
* @param {?=} transactionParam Optional pre-existing transaction to use for the read request
* @return {?} The item's value if the key exists, null otherwise, wrapped in an RxJS Observable
*/
function (key, transactionParam) {
var _this = this;
/* Opening a trasaction and requesting the item in local storage */
return this.transaction().pipe(rxjs_operators.map(function (transaction) { return transaction.get(key); }), rxjs_operators.mergeMap(function (request) {
var /** @type {?} */ transaction$ = transactionParam ? rxjs_observable_of.of(transactionParam) : this.transaction();
return transaction$.pipe(rxjs_operators.map(function (transaction) { return transaction.get(key); }), rxjs_operators.mergeMap(function (request) {
/* Listening to the success event, and passing the item value if found, null otherwise */

@@ -142,22 +162,24 @@ var /** @type {?} */ success = (/** @type {?} */ (rxjs_observable_fromEvent.fromEvent(request, 'success'))).pipe(rxjs_operators.map(function (event) { return (/** @type {?} */ (event.target)).result; }), rxjs_operators.map(function (result) { return result && (_this.dataPath in result) ? (/** @type {?} */ (result[_this.dataPath])) : null; }));

}
/* Opening a transaction and checking if the item already exists in local storage */
return this.getItem(key).pipe(rxjs_operators.map(function (existingData) { return (existingData == null) ? 'add' : 'put'; }), rxjs_operators.mergeMap(function (method) {
/* Opening a transaction */
return _this.transaction('readwrite').pipe(rxjs_operators.mergeMap(function (transaction) {
var /** @type {?} */ request;
/* Adding or updating local storage, based on previous checking */
switch (method) {
case 'add':
request = transaction.add((_a = {}, _a[_this.dataPath] = data, _a), key);
break;
case 'put':
default:
request = transaction.put((_b = {}, _b[_this.dataPath] = data, _b), key);
break;
}
/* Merging success (passing true) and error events and autoclosing the observable */
return (/** @type {?} */ (rxjs_observable_race.race(_this.toSuccessObservable(request), _this.toErrorObservable(request, "setter"))))
.pipe(rxjs_operators.first());
var _a, _b;
}));
/* Transaction must be the same for read and write, to avoid concurrency issues */
var /** @type {?} */ transaction$ = this.transaction('readwrite');
var /** @type {?} */ transaction;
return transaction$.pipe(rxjs_operators.tap(function (value) {
transaction = value;
}), /* Check if the key already exists or not */
rxjs_operators.mergeMap(function () { return _this.getItemFromTransaction(key, transaction); }), rxjs_operators.map(function (existingData) { return (existingData == null) ? 'add' : 'put'; }), rxjs_operators.mergeMap(function (method) {
var /** @type {?} */ request;
/* Adding or updating local storage, based on previous checking */
switch (method) {
case 'add':
request = transaction.add((_a = {}, _a[_this.dataPath] = data, _a), key);
break;
case 'put':
default:
request = transaction.put((_b = {}, _b[_this.dataPath] = data, _b), key);
break;
}
/* Merging success (passing true) and error events and autoclosing the observable */
return (/** @type {?} */ (rxjs_observable_race.race(_this.toSuccessObservable(request), _this.toErrorObservable(request, "setter"))))
.pipe(rxjs_operators.first());
var _a, _b;
}), rxjs_operators.first());

@@ -164,0 +186,0 @@ };

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs/ReplaySubject"),require("rxjs/operators"),require("rxjs/observable/fromEvent"),require("rxjs/observable/of"),require("rxjs/observable/throw"),require("rxjs/observable/race"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/ReplaySubject","rxjs/operators","rxjs/observable/fromEvent","rxjs/observable/of","rxjs/observable/throw","rxjs/observable/race","@angular/common"],t):t((e.ngxPWA=e.ngxPWA||{},e.ngxPWA.localStorage=e.ngxPWA.localStorage||{}),e.ng.core,e.Rx,e.Rx.operators,e.Rx.Observable,e.Rx.Observable,e.Rx.Observable,e.Rx.Observable,e.ng.common)}(this,function(e,t,r,o,n,a,i,s,u){"use strict";function c(e,t){return u.isPlatformBrowser(e)&&"indexedDB"in window&&void 0!==indexedDB&&null!==indexedDB?new y(t):u.isPlatformBrowser(e)&&"localStorage"in window&&void 0!==localStorage&&null!==localStorage?new d(t):new h}var p=function(){return function(){}}(),l=new t.InjectionToken("localStoragePrefix"),f=function(){var e=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])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),y=function(e){function u(t){void 0===t&&(t=null);var o=e.call(this)||this;return o.prefix=t,o.dbName="ngStorage",o.objectStoreName="localStorage",o.keyPath="key",o.dataPath="value",t&&(o.dbName=t+"_"+o.dbName),o.database=new r.ReplaySubject,o.connect(),o}return f(u,e),u.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 s.race(r,t.toErrorObservable(e,"getter")).pipe(o.first())}),o.first())},u.prototype.setItem=function(e,t){var r=this;return null==t?a.of(!0):this.getItem(e).pipe(o.map(function(e){return null==e?"add":"put"}),o.mergeMap(function(n){return r.transaction("readwrite").pipe(o.mergeMap(function(a){var i;switch(n){case"add":i=a.add((u={},u[r.dataPath]=t,u),e);break;case"put":default:i=a.put((c={},c[r.dataPath]=t,c),e)}return s.race(r.toSuccessObservable(i),r.toErrorObservable(i,"setter")).pipe(o.first());var u,c}))}),o.first())},u.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 n=r.delete(e);return s.race(t.toSuccessObservable(n),t.toErrorObservable(n,"remover")).pipe(o.first())})):a.of(!0)}),o.first())},u.prototype.clear=function(){var e=this;return this.transaction("readwrite").pipe(o.mergeMap(function(t){var r=t.clear();return s.race(e.toSuccessObservable(r),e.toErrorObservable(r,"clearer")).pipe(o.first())}),o.first())},u.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");s.race(r,this.toErrorObservable(t,"connection")).pipe(o.first()).subscribe(function(t){e.database.next(t.target.result)},function(t){e.database.error(t)})},u.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)}))},u.prototype.toSuccessObservable=function(e){return n.fromEvent(e,"success").pipe(o.map(function(){return!0}))},u.prototype.toErrorObservable=function(e,t){return void 0===t&&(t=""),n.fromEvent(e,"error").pipe(o.mergeMap(function(r){return i._throw(new Error("IndexedDB "+t+" issue : "+e.error.message+"."))}))},u.decorators=[{type:t.Injectable}],u.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[l]}]}]},u}(p),b=function(){var e=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])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),d=function(e){function r(t){void 0===t&&(t=null);var r=e.call(this)||this;return r.userPrefix=t,r.prefix="",t&&(r.prefix=t+"_"),r}return b(r,e),r.prototype.getItem=function(e){var t=localStorage.getItem(""+this.prefix+e),r=null;if(null!=t)try{r=JSON.parse(t)}catch(e){return i._throw(new Error("Invalid data in localStorage."))}return a.of(r)},r.prototype.setItem=function(e,t){return localStorage.setItem(""+this.prefix+e,JSON.stringify(t)),a.of(!0)},r.prototype.removeItem=function(e){return localStorage.removeItem(""+this.prefix+e),a.of(!0)},r.prototype.clear=function(){return localStorage.clear(),a.of(!0)},r.decorators=[{type:t.Injectable}],r.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[l]}]}]},r}(p),m=function(){var e=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])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),h=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.localStorage=new Map,t}return m(r,e),r.prototype.getItem=function(e){var t=this.localStorage.get(e);return a.of(void 0!==t?t:null)},r.prototype.setItem=function(e,t){return this.localStorage.set(e,t),a.of(!0)},r.prototype.removeItem=function(e){return this.localStorage.delete(e),a.of(!0)},r.prototype.clear=function(){return this.localStorage.clear(),a.of(!0)},r.decorators=[{type:t.Injectable}],r.ctorParameters=function(){return[]},r}(p),v=function(){function e(){this.simpleTypes=["string","number","boolean","object"]}return e.prototype.isObjectNotNull=function(e){return null!==e&&"object"==typeof e},e.prototype.validate=function(e,t){if(!this.isObjectNotNull(t))throw new Error("A schema must be an object (unlike spec, booleans are not supported to enforce strict types).");if(!(t.hasOwnProperty("type")&&"array"!==t.type&&"object"!==t.type||t.hasOwnProperty("properties")||t.hasOwnProperty("items")))throw new Error("Each value must have a 'type' or 'properties' or 'items', to enforce strict types.");if(t.hasOwnProperty("type")&&!this.validateType(e,t))return!1;if(t.hasOwnProperty("items")&&!this.validateItems(e,t))return!1;if(t.hasOwnProperty("properties")){if(t.hasOwnProperty("required")&&!this.validateRequired(e,t))return!1;if(!this.validateProperties(e,t))return!1}return!0},e.prototype.validateProperties=function(e,t){if(!this.isObjectNotNull(e))return!1;if(!t.properties||!this.isObjectNotNull(t.properties))throw new Error("'properties' must be a schema object.");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(!this.isObjectNotNull(e))return!1;if(!Array.isArray(t.required))throw new Error("'required' field must be an array. Note that since JSON Schema draft 6, booleans are not supported anymore.");for(var r=0,o=t.required;r<o.length;r++){var n=o[r];if("string"!=typeof n)throw new Error("'required' array must contain strings only.");if(!t.properties||!t.properties.hasOwnProperty(n))throw new Error("'required' properties must be described in 'properties' too.");if(!e.hasOwnProperty(n))return!1}return!0},e.prototype.validateType=function(e,t){if(Array.isArray(t.type))return this.validateTypeList(e,t);if("string"!=typeof t.type)throw new Error("'type' must be a string (arrays of types are not supported yet).");return("null"!==t.type||null===e)&&((-1===this.simpleTypes.indexOf(t.type)||typeof e===t.type)&&!!("integer"!==t.type||"number"==typeof e&&Number.isInteger(e)))},e.prototype.validateTypeList=function(e,t){for(var r=[],o=0,n=t.type;o<n.length;o++){var a=n[o];r.push(this.validateType(e,{type:a}))}return-1!==r.indexOf(!0)},e.prototype.validateItems=function(e,t){if(!Array.isArray(e))return!1;if(Array.isArray(t.items))return this.validateItemsList(e,t);if(!t.items||!this.isObjectNotNull(t.items))throw new Error("'items' must be a schema object.");for(var r=0,o=e;r<o.length;r++){var n=o[r];if(!this.validate(n,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 o=0;o<r.length;o+=1)if(!this.validate(e[o],r[o]))return!1;return!0},e}(),g=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 i._throw(e)}if(!o)return i._throw(new Error("JSON invalid"))}return a.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}],e.ctorParameters=function(){return[{type:p},{type:v}]},e}(),O=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{providers:[v,{provide:p,useFactory:c,deps:[t.PLATFORM_ID,[new t.Optional,l]]},g]}]}],e.ctorParameters=function(){return[]},e}();e.LocalDatabase=p,e.IndexedDBDatabase=y,e.LocalStorageDatabase=d,e.MockLocalDatabase=h,e.JSONValidator=v,e.LocalStorage=g,e.LocalStorageModule=O,e.localStorageProviders=function(e){return[e.prefix?{provide:l,useValue:e.prefix}:[]]},e.LOCAL_STORAGE_PREFIX=l,e.AsyncLocalStorage=g,e.AsyncLocalDatabase=p,e.AsyncLocalStorageModule=O,e.ɵa=c,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs/ReplaySubject"),require("rxjs/operators"),require("rxjs/observable/fromEvent"),require("rxjs/observable/of"),require("rxjs/observable/throw"),require("rxjs/observable/race"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/ReplaySubject","rxjs/operators","rxjs/observable/fromEvent","rxjs/observable/of","rxjs/observable/throw","rxjs/observable/race","@angular/common"],t):t((e.ngxPWA=e.ngxPWA||{},e.ngxPWA.localStorage=e.ngxPWA.localStorage||{}),e.ng.core,e.Rx,e.Rx.operators,e.Rx.Observable,e.Rx.Observable,e.Rx.Observable,e.Rx.Observable,e.ng.common)}(this,function(e,t,r,o,n,a,i,s,u){"use strict";function c(e,t){return u.isPlatformBrowser(e)&&"indexedDB"in window&&void 0!==indexedDB&&null!==indexedDB?new y(t):u.isPlatformBrowser(e)&&"localStorage"in window&&void 0!==localStorage&&null!==localStorage?new d(t):new h}var p=function(){return function(){}}(),l=new t.InjectionToken("localStoragePrefix"),f=function(){var e=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])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),y=function(e){function u(t){void 0===t&&(t=null);var o=e.call(this)||this;return o.prefix=t,o.dbName="ngStorage",o.objectStoreName="localStorage",o.keyPath="key",o.dataPath="value",t&&(o.dbName=t+"_"+o.dbName),o.database=new r.ReplaySubject,o.connect(),o}return f(u,e),u.prototype.getItem=function(e){return this.getItemFromTransaction(e)},u.prototype.getItemFromTransaction=function(e,t){var r=this;return(t?a.of(t):this.transaction()).pipe(o.map(function(t){return t.get(e)}),o.mergeMap(function(e){var t=n.fromEvent(e,"success").pipe(o.map(function(e){return e.target.result}),o.map(function(e){return e&&r.dataPath in e?e[r.dataPath]:null}));return s.race(t,r.toErrorObservable(e,"getter")).pipe(o.first())}),o.first())},u.prototype.setItem=function(e,t){var r=this;if(null==t)return a.of(!0);var n;return this.transaction("readwrite").pipe(o.tap(function(e){n=e}),o.mergeMap(function(){return r.getItemFromTransaction(e,n)}),o.map(function(e){return null==e?"add":"put"}),o.mergeMap(function(a){var i;switch(a){case"add":i=n.add((u={},u[r.dataPath]=t,u),e);break;case"put":default:i=n.put((c={},c[r.dataPath]=t,c),e)}return s.race(r.toSuccessObservable(i),r.toErrorObservable(i,"setter")).pipe(o.first());var u,c}),o.first())},u.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 n=r.delete(e);return s.race(t.toSuccessObservable(n),t.toErrorObservable(n,"remover")).pipe(o.first())})):a.of(!0)}),o.first())},u.prototype.clear=function(){var e=this;return this.transaction("readwrite").pipe(o.mergeMap(function(t){var r=t.clear();return s.race(e.toSuccessObservable(r),e.toErrorObservable(r,"clearer")).pipe(o.first())}),o.first())},u.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");s.race(r,this.toErrorObservable(t,"connection")).pipe(o.first()).subscribe(function(t){e.database.next(t.target.result)},function(t){e.database.error(t)})},u.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)}))},u.prototype.toSuccessObservable=function(e){return n.fromEvent(e,"success").pipe(o.map(function(){return!0}))},u.prototype.toErrorObservable=function(e,t){return void 0===t&&(t=""),n.fromEvent(e,"error").pipe(o.mergeMap(function(r){return i._throw(new Error("IndexedDB "+t+" issue : "+e.error.message+"."))}))},u.decorators=[{type:t.Injectable}],u.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[l]}]}]},u}(p),b=function(){var e=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])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),d=function(e){function r(t){void 0===t&&(t=null);var r=e.call(this)||this;return r.userPrefix=t,r.prefix="",t&&(r.prefix=t+"_"),r}return b(r,e),r.prototype.getItem=function(e){var t=localStorage.getItem(""+this.prefix+e),r=null;if(null!=t)try{r=JSON.parse(t)}catch(e){return i._throw(new Error("Invalid data in localStorage."))}return a.of(r)},r.prototype.setItem=function(e,t){return localStorage.setItem(""+this.prefix+e,JSON.stringify(t)),a.of(!0)},r.prototype.removeItem=function(e){return localStorage.removeItem(""+this.prefix+e),a.of(!0)},r.prototype.clear=function(){return localStorage.clear(),a.of(!0)},r.decorators=[{type:t.Injectable}],r.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[l]}]}]},r}(p),m=function(){var e=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])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),h=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.localStorage=new Map,t}return m(r,e),r.prototype.getItem=function(e){var t=this.localStorage.get(e);return a.of(void 0!==t?t:null)},r.prototype.setItem=function(e,t){return this.localStorage.set(e,t),a.of(!0)},r.prototype.removeItem=function(e){return this.localStorage.delete(e),a.of(!0)},r.prototype.clear=function(){return this.localStorage.clear(),a.of(!0)},r.decorators=[{type:t.Injectable}],r.ctorParameters=function(){return[]},r}(p),v=function(){function e(){this.simpleTypes=["string","number","boolean","object"]}return e.prototype.isObjectNotNull=function(e){return null!==e&&"object"==typeof e},e.prototype.validate=function(e,t){if(!this.isObjectNotNull(t))throw new Error("A schema must be an object (unlike spec, booleans are not supported to enforce strict types).");if(!(t.hasOwnProperty("type")&&"array"!==t.type&&"object"!==t.type||t.hasOwnProperty("properties")||t.hasOwnProperty("items")))throw new Error("Each value must have a 'type' or 'properties' or 'items', to enforce strict types.");if(t.hasOwnProperty("type")&&!this.validateType(e,t))return!1;if(t.hasOwnProperty("items")&&!this.validateItems(e,t))return!1;if(t.hasOwnProperty("properties")){if(t.hasOwnProperty("required")&&!this.validateRequired(e,t))return!1;if(!this.validateProperties(e,t))return!1}return!0},e.prototype.validateProperties=function(e,t){if(!this.isObjectNotNull(e))return!1;if(!t.properties||!this.isObjectNotNull(t.properties))throw new Error("'properties' must be a schema object.");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(!this.isObjectNotNull(e))return!1;if(!Array.isArray(t.required))throw new Error("'required' field must be an array. Note that since JSON Schema draft 6, booleans are not supported anymore.");for(var r=0,o=t.required;r<o.length;r++){var n=o[r];if("string"!=typeof n)throw new Error("'required' array must contain strings only.");if(!t.properties||!t.properties.hasOwnProperty(n))throw new Error("'required' properties must be described in 'properties' too.");if(!e.hasOwnProperty(n))return!1}return!0},e.prototype.validateType=function(e,t){if(Array.isArray(t.type))return this.validateTypeList(e,t);if("string"!=typeof t.type)throw new Error("'type' must be a string (arrays of types are not supported yet).");return("null"!==t.type||null===e)&&((-1===this.simpleTypes.indexOf(t.type)||typeof e===t.type)&&!!("integer"!==t.type||"number"==typeof e&&Number.isInteger(e)))},e.prototype.validateTypeList=function(e,t){for(var r=[],o=0,n=t.type;o<n.length;o++){var a=n[o];r.push(this.validateType(e,{type:a}))}return-1!==r.indexOf(!0)},e.prototype.validateItems=function(e,t){if(!Array.isArray(e))return!1;if(Array.isArray(t.items))return this.validateItemsList(e,t);if(!t.items||!this.isObjectNotNull(t.items))throw new Error("'items' must be a schema object.");for(var r=0,o=e;r<o.length;r++){var n=o[r];if(!this.validate(n,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 o=0;o<r.length;o+=1)if(!this.validate(e[o],r[o]))return!1;return!0},e}(),g=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 i._throw(e)}if(!o)return i._throw(new Error("JSON invalid"))}return a.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}],e.ctorParameters=function(){return[{type:p},{type:v}]},e}(),O=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{providers:[v,{provide:p,useFactory:c,deps:[t.PLATFORM_ID,[new t.Optional,l]]},g]}]}],e.ctorParameters=function(){return[]},e}();e.LocalDatabase=p,e.IndexedDBDatabase=y,e.LocalStorageDatabase=d,e.MockLocalDatabase=h,e.JSONValidator=v,e.LocalStorage=g,e.LocalStorageModule=O,e.localStorageProviders=function(e){return[e.prefix?{provide:l,useValue:e.prefix}:[]]},e.LOCAL_STORAGE_PREFIX=l,e.AsyncLocalStorage=g,e.AsyncLocalDatabase=p,e.AsyncLocalStorageModule=O,e.ɵa=c,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=local-storage.umd.min.js.map
import { Inject, Injectable, InjectionToken, NgModule, Optional, PLATFORM_ID } from '@angular/core';
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { first, map, mergeMap } from 'rxjs/operators';
import { first, map, mergeMap, tap } from 'rxjs/operators';
import { fromEvent } from 'rxjs/observable/fromEvent';

@@ -110,5 +110,25 @@ import { of } from 'rxjs/observable/of';

function (key) {
/* Opening a trasaction and requesting the item in local storage */
return this.getItemFromTransaction(key);
};
/**
* Internal method to factorize the getter for getItem and setItem,
* the last one needing to be from a preexisting transaction
* @template T
* @param {?} key The item's key
* @param {?=} transactionParam Optional pre-existing transaction to use for the read request
* @return {?} The item's value if the key exists, null otherwise, wrapped in an RxJS Observable
*/
IndexedDBDatabase.prototype.getItemFromTransaction = /**
* Internal method to factorize the getter for getItem and setItem,
* the last one needing to be from a preexisting transaction
* @template T
* @param {?} key The item's key
* @param {?=} transactionParam Optional pre-existing transaction to use for the read request
* @return {?} The item's value if the key exists, null otherwise, wrapped in an RxJS Observable
*/
function (key, transactionParam) {
var _this = this;
/* Opening a trasaction and requesting the item in local storage */
return this.transaction().pipe(map(function (transaction) { return transaction.get(key); }), mergeMap(function (request) {
var /** @type {?} */ transaction$ = transactionParam ? of(transactionParam) : this.transaction();
return transaction$.pipe(map(function (transaction) { return transaction.get(key); }), mergeMap(function (request) {
/* Listening to the success event, and passing the item value if found, null otherwise */

@@ -145,22 +165,24 @@ var /** @type {?} */ success = (/** @type {?} */ (fromEvent(request, 'success'))).pipe(map(function (event) { return (/** @type {?} */ (event.target)).result; }), map(function (result) { return result && (_this.dataPath in result) ? (/** @type {?} */ (result[_this.dataPath])) : null; }));

}
/* Opening a transaction and checking if the item already exists in local storage */
return this.getItem(key).pipe(map(function (existingData) { return (existingData == null) ? 'add' : 'put'; }), mergeMap(function (method) {
/* Opening a transaction */
return _this.transaction('readwrite').pipe(mergeMap(function (transaction) {
var /** @type {?} */ request;
/* Adding or updating local storage, based on previous checking */
switch (method) {
case 'add':
request = transaction.add((_a = {}, _a[_this.dataPath] = data, _a), key);
break;
case 'put':
default:
request = transaction.put((_b = {}, _b[_this.dataPath] = data, _b), key);
break;
}
/* Merging success (passing true) and error events and autoclosing the observable */
return (/** @type {?} */ (race(_this.toSuccessObservable(request), _this.toErrorObservable(request, "setter"))))
.pipe(first());
var _a, _b;
}));
/* Transaction must be the same for read and write, to avoid concurrency issues */
var /** @type {?} */ transaction$ = this.transaction('readwrite');
var /** @type {?} */ transaction;
return transaction$.pipe(tap(function (value) {
transaction = value;
}), /* Check if the key already exists or not */
mergeMap(function () { return _this.getItemFromTransaction(key, transaction); }), map(function (existingData) { return (existingData == null) ? 'add' : 'put'; }), mergeMap(function (method) {
var /** @type {?} */ request;
/* Adding or updating local storage, based on previous checking */
switch (method) {
case 'add':
request = transaction.add((_a = {}, _a[_this.dataPath] = data, _a), key);
break;
case 'put':
default:
request = transaction.put((_b = {}, _b[_this.dataPath] = data, _b), key);
break;
}
/* Merging success (passing true) and error events and autoclosing the observable */
return (/** @type {?} */ (race(_this.toSuccessObservable(request), _this.toErrorObservable(request, "setter"))))
.pipe(first());
var _a, _b;
}), first());

@@ -167,0 +189,0 @@ };

import { Inject, Injectable, InjectionToken, NgModule, Optional, PLATFORM_ID } from '@angular/core';
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { first, map, mergeMap } from 'rxjs/operators';
import { first, map, mergeMap, tap } from 'rxjs/operators';
import { fromEvent } from 'rxjs/observable/fromEvent';

@@ -83,3 +83,15 @@ import { of } from 'rxjs/observable/of';

/* Opening a trasaction and requesting the item in local storage */
return this.transaction().pipe(map((transaction) => transaction.get(key)), mergeMap((request) => {
return this.getItemFromTransaction(key);
}
/**
* Internal method to factorize the getter for getItem and setItem,
* the last one needing to be from a preexisting transaction
* @template T
* @param {?} key The item's key
* @param {?=} transactionParam Optional pre-existing transaction to use for the read request
* @return {?} The item's value if the key exists, null otherwise, wrapped in an RxJS Observable
*/
getItemFromTransaction(key, transactionParam) {
const /** @type {?} */ transaction$ = transactionParam ? of(transactionParam) : this.transaction();
return transaction$.pipe(map((transaction) => transaction.get(key)), mergeMap((request) => {
/* Listening to the success event, and passing the item value if found, null otherwise */

@@ -103,21 +115,23 @@ const /** @type {?} */ success = (/** @type {?} */ (fromEvent(request, 'success'))).pipe(map((event) => (/** @type {?} */ (event.target)).result), map((result) => result && (this.dataPath in result) ? (/** @type {?} */ (result[this.dataPath])) : null));

}
/* Opening a transaction and checking if the item already exists in local storage */
return this.getItem(key).pipe(map((existingData) => (existingData == null) ? 'add' : 'put'), mergeMap((method) => {
/* Opening a transaction */
return this.transaction('readwrite').pipe(mergeMap((transaction) => {
let /** @type {?} */ request;
/* Adding or updating local storage, based on previous checking */
switch (method) {
case 'add':
request = transaction.add({ [this.dataPath]: data }, key);
break;
case 'put':
default:
request = transaction.put({ [this.dataPath]: data }, key);
break;
}
/* Merging success (passing true) and error events and autoclosing the observable */
return (/** @type {?} */ (race(this.toSuccessObservable(request), this.toErrorObservable(request, `setter`))))
.pipe(first());
}));
/* Transaction must be the same for read and write, to avoid concurrency issues */
const /** @type {?} */ transaction$ = this.transaction('readwrite');
let /** @type {?} */ transaction;
return transaction$.pipe(tap((value) => {
transaction = value;
}), /* Check if the key already exists or not */
mergeMap(() => this.getItemFromTransaction(key, transaction)), map((existingData) => (existingData == null) ? 'add' : 'put'), mergeMap((method) => {
let /** @type {?} */ request;
/* Adding or updating local storage, based on previous checking */
switch (method) {
case 'add':
request = transaction.add({ [this.dataPath]: data }, key);
break;
case 'put':
default:
request = transaction.put({ [this.dataPath]: data }, key);
break;
}
/* Merging success (passing true) and error events and autoclosing the observable */
return (/** @type {?} */ (race(this.toSuccessObservable(request), this.toErrorObservable(request, `setter`))))
.pipe(first());
}), first());

@@ -124,0 +138,0 @@ }

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

{"__symbolic":"module","version":4,"metadata":{"JSONSchema":{"__symbolic":"interface"},"JSONSchemaType":{"__symbolic":"interface"},"LocalDatabase":{"__symbolic":"class","members":{"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}]}},"IndexedDBDatabase":{"__symbolic":"class","extends":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":13,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":41,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":41,"character":27},"arguments":[{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"}]}]],"parameters":[{"__symbolic":"reference","name":"string"}]}],"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}],"connect":[{"__symbolic":"method"}],"transaction":[{"__symbolic":"method"}],"toSuccessObservable":[{"__symbolic":"method"}],"toErrorObservable":[{"__symbolic":"method"}]}},"LocalStorageDatabase":{"__symbolic":"class","extends":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":9,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":17,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":17,"character":27},"arguments":[{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"}]}]],"parameters":[{"__symbolic":"reference","name":"string"}]}],"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}]}},"MockLocalDatabase":{"__symbolic":"class","extends":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":7,"character":1}}],"members":{"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}]}},"JSONValidator":{"__symbolic":"class","members":{"isObjectNotNull":[{"__symbolic":"method"}],"validate":[{"__symbolic":"method"}],"validateProperties":[{"__symbolic":"method"}],"validateRequired":[{"__symbolic":"method"}],"validateType":[{"__symbolic":"method"}],"validateTypeList":[{"__symbolic":"method"}],"validateItems":[{"__symbolic":"method"}],"validateItemsList":[{"__symbolic":"method"}]}},"LSGetItemOptions":{"__symbolic":"interface"},"LocalStorage":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":14,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"AsyncLocalDatabase"},{"__symbolic":"reference","name":"JSONValidator"}]}],"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}],"setItemSubscribe":[{"__symbolic":"method"}],"removeItemSubscribe":[{"__symbolic":"method"}],"clearSubscribe":[{"__symbolic":"method"}]}},"ɵa":{"__symbolic":"function"},"LocalStorageModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":32,"character":1},"arguments":[{"providers":[{"__symbolic":"reference","name":"JSONValidator"},{"provide":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"useFactory":{"__symbolic":"reference","name":"ɵa"},"deps":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID","line":38,"character":13},[{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":38,"character":31}},{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"}]]},{"__symbolic":"reference","name":"AsyncLocalStorage"}]}]}],"members":{}},"localStorageProviders":{"__symbolic":"function","parameters":["config"],"value":[{"__symbolic":"if","condition":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"prefix"},"thenExpression":{"provide":{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"},"useValue":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"prefix"}},"elseExpression":[]}]},"LocalStorageProvidersConfig":{"__symbolic":"interface"},"LOCAL_STORAGE_PREFIX":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":2,"character":40},"arguments":["localStoragePrefix"]},"AsyncLocalStorage":{"__symbolic":"reference","name":"LocalStorage"},"ALSGetItemOptions":{"__symbolic":"reference","name":"LSGetItemOptions"},"AsyncLocalDatabase":{"__symbolic":"reference","name":"LocalDatabase"},"AsyncLocalStorageModule":{"__symbolic":"reference","name":"LocalStorageModule"}},"origins":{"JSONSchema":"./src/service/validation/json-schema","JSONSchemaType":"./src/service/validation/json-schema","LocalDatabase":"./src/service/databases/local-database","IndexedDBDatabase":"./src/service/databases/indexeddb-database","LocalStorageDatabase":"./src/service/databases/localstorage-database","MockLocalDatabase":"./src/service/databases/mock-local-database","JSONValidator":"./src/service/validation/json-validator","LSGetItemOptions":"./src/service/lib.service","LocalStorage":"./src/service/lib.service","ɵa":"./src/module","LocalStorageModule":"./src/module","localStorageProviders":"./src/tokens","LocalStorageProvidersConfig":"./src/tokens","LOCAL_STORAGE_PREFIX":"./src/tokens","AsyncLocalStorage":"./src/service/lib.service","ALSGetItemOptions":"./src/service/lib.service","AsyncLocalDatabase":"./src/service/databases/local-database","AsyncLocalStorageModule":"./src/module"},"importAs":"@ngx-pwa/local-storage"}
{"__symbolic":"module","version":4,"metadata":{"JSONSchema":{"__symbolic":"interface"},"JSONSchemaType":{"__symbolic":"interface"},"LocalDatabase":{"__symbolic":"class","members":{"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}]}},"IndexedDBDatabase":{"__symbolic":"class","extends":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":13,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":41,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":41,"character":27},"arguments":[{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"}]}]],"parameters":[{"__symbolic":"reference","name":"string"}]}],"getItem":[{"__symbolic":"method"}],"getItemFromTransaction":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}],"connect":[{"__symbolic":"method"}],"transaction":[{"__symbolic":"method"}],"toSuccessObservable":[{"__symbolic":"method"}],"toErrorObservable":[{"__symbolic":"method"}]}},"LocalStorageDatabase":{"__symbolic":"class","extends":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":9,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":17,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":17,"character":27},"arguments":[{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"}]}]],"parameters":[{"__symbolic":"reference","name":"string"}]}],"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}]}},"MockLocalDatabase":{"__symbolic":"class","extends":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":7,"character":1}}],"members":{"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}]}},"JSONValidator":{"__symbolic":"class","members":{"isObjectNotNull":[{"__symbolic":"method"}],"validate":[{"__symbolic":"method"}],"validateProperties":[{"__symbolic":"method"}],"validateRequired":[{"__symbolic":"method"}],"validateType":[{"__symbolic":"method"}],"validateTypeList":[{"__symbolic":"method"}],"validateItems":[{"__symbolic":"method"}],"validateItemsList":[{"__symbolic":"method"}]}},"LSGetItemOptions":{"__symbolic":"interface"},"LocalStorage":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":14,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"AsyncLocalDatabase"},{"__symbolic":"reference","name":"JSONValidator"}]}],"getItem":[{"__symbolic":"method"}],"setItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}],"setItemSubscribe":[{"__symbolic":"method"}],"removeItemSubscribe":[{"__symbolic":"method"}],"clearSubscribe":[{"__symbolic":"method"}]}},"ɵa":{"__symbolic":"function"},"LocalStorageModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":32,"character":1},"arguments":[{"providers":[{"__symbolic":"reference","name":"JSONValidator"},{"provide":{"__symbolic":"reference","name":"AsyncLocalDatabase"},"useFactory":{"__symbolic":"reference","name":"ɵa"},"deps":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID","line":38,"character":13},[{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":38,"character":31}},{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"}]]},{"__symbolic":"reference","name":"AsyncLocalStorage"}]}]}],"members":{}},"localStorageProviders":{"__symbolic":"function","parameters":["config"],"value":[{"__symbolic":"if","condition":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"prefix"},"thenExpression":{"provide":{"__symbolic":"reference","name":"LOCAL_STORAGE_PREFIX"},"useValue":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"prefix"}},"elseExpression":[]}]},"LocalStorageProvidersConfig":{"__symbolic":"interface"},"LOCAL_STORAGE_PREFIX":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":2,"character":40},"arguments":["localStoragePrefix"]},"AsyncLocalStorage":{"__symbolic":"reference","name":"LocalStorage"},"ALSGetItemOptions":{"__symbolic":"reference","name":"LSGetItemOptions"},"AsyncLocalDatabase":{"__symbolic":"reference","name":"LocalDatabase"},"AsyncLocalStorageModule":{"__symbolic":"reference","name":"LocalStorageModule"}},"origins":{"JSONSchema":"./src/service/validation/json-schema","JSONSchemaType":"./src/service/validation/json-schema","LocalDatabase":"./src/service/databases/local-database","IndexedDBDatabase":"./src/service/databases/indexeddb-database","LocalStorageDatabase":"./src/service/databases/localstorage-database","MockLocalDatabase":"./src/service/databases/mock-local-database","JSONValidator":"./src/service/validation/json-validator","LSGetItemOptions":"./src/service/lib.service","LocalStorage":"./src/service/lib.service","ɵa":"./src/module","LocalStorageModule":"./src/module","localStorageProviders":"./src/tokens","LocalStorageProvidersConfig":"./src/tokens","LOCAL_STORAGE_PREFIX":"./src/tokens","AsyncLocalStorage":"./src/service/lib.service","ALSGetItemOptions":"./src/service/lib.service","AsyncLocalDatabase":"./src/service/databases/local-database","AsyncLocalStorageModule":"./src/module"},"importAs":"@ngx-pwa/local-storage"}
{
"name": "@ngx-pwa/local-storage",
"version": "5.3.0",
"version": "5.3.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.",

@@ -5,0 +5,0 @@ "main": "./bundles/local-storage.umd.js",

@@ -36,4 +36,12 @@ import { Observable } from 'rxjs/Observable';

*/
getItem<T = any>(key: string): Observable<T | null>;
getItem<T = any>(key: string): Observable<any>;
/**
* Internal method to factorize the getter for getItem and setItem,
* the last one needing to be from a preexisting transaction
* @param key The item's key
* @param transactionParam Optional pre-existing transaction to use for the read request
* @returns The item's value if the key exists, null otherwise, wrapped in an RxJS Observable
*/
private getItemFromTransaction<T>(key, transactionParam?);
/**
* Sets an item in local storage

@@ -40,0 +48,0 @@ * @param key The item's key

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc