@browser-storage/core
Advanced tools
Comparing version 0.0.1-alpha.4 to 0.0.1-alpha.5
@@ -1,1 +0,1 @@ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e);var n,o,i=(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function s(t){switch(t.type){case o.Clear:return new l(t);case o.SetItem:return new a(t);case o.RemoveItem:return new c(t);default:return new u(t)}}!function(t){t[t.Default=0]="Default",t[t.SetItem=1]="SetItem",t[t.RemoveItem=2]="RemoveItem",t[t.Clear=3]="Clear"}(o||(o={}));var u=function(){function t(t){var e=t.name,r=t.storeName,n=t.version,i=t.key,s=t.oldValue,u=t.newValue,a=t.isCrossTab,c=void 0!==a&&a;this.type=o.Default,this.name=e,this.storeName=r,this.version=n,this.key=i,this.oldValue=s,this.newValue=u,this.isCrossTab=c}return t.deserialize=function(t){return s(JSON.parse(t))},t.serialize=function(t){return JSON.stringify(t)},t.prototype.copyWith=function(t){var e=t.name,r=void 0===e?this.name:e,n=t.storeName,o=void 0===n?this.storeName:n,i=t.version,u=void 0===i?this.version:i,a=t.key,c=void 0===a?this.key:a,l=t.oldValue,f=void 0===l?this.oldValue:l,p=t.newValue,h=void 0===p?this.newValue:p,d=t.isCrossTab,v=void 0===d?this.isCrossTab:d;return s({type:this.type,name:r,storeName:o,version:u,key:c,oldValue:f,newValue:h,isCrossTab:v})},t}(),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.SetItem,e}return i(e,t),e}(u),c=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.RemoveItem,e}return i(e,t),e}(u),l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.Clear,e}return i(e,t),e}(u),f=function(){return(f=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},p=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(o=t[u])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},h=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{a(n.next(t))}catch(t){i(t)}}function u(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}a((n=n.apply(t,e||[])).next())})},d=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};function v(t,e,r){var n=r.value;r.value=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return h(this,void 0,void 0,function(){return d(this,function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[2,n.apply(this,t)]}})})}}var y="__browser_storage_event_",m=function(){function t(t){var e=this;this._handlerStore=new Set,this._storageChange=function(t){if(t.key===y){var r=localStorage.getItem(y),n=u.deserialize(r);n.name===e.options.name&&n.storeName===e.options.storeName&&e._applyHandlers(n)}},this._driver=(Array.isArray(t.drivers)?t.drivers:[t.drivers]).find(function(t){return t.isSupported}),this.options=f({},t,{drivers:void 0}),this.init(t)}return Object.defineProperty(t.prototype,"isSupported",{get:function(){return!!this._driver&&this._driver.isSupported},enumerable:!0,configurable:!0}),t.prototype.ready=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,!!this._driver&&this._driver.isSupported&&this._driver.ready()]})})},t.prototype.clear=function(){return h(this,void 0,void 0,function(){var t;return d(this,function(e){switch(e.label){case 0:return[4,this._driver.clear()];case 1:return e.sent(),t=new l({name:this.options.name,storeName:this.options.storeName,version:this.options.version,key:null,oldValue:null,newValue:null}),this._triggerEvent(t),[2]}})})},t.prototype.getItem=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.getItem(t)]})})},t.prototype.iterate=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.iterate(t)]})})},t.prototype.key=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.key(t)]})})},t.prototype.keys=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,this._driver.keys()]})})},t.prototype.length=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,this._driver.length()]})})},t.prototype.removeItem=function(t){return h(this,void 0,void 0,function(){var e,r,n;return d(this,function(o){switch(o.label){case 0:return[4,this.hasItem(t)];case 1:return o.sent()?[4,this.getItem(t)]:[3,3];case 2:return r=o.sent(),[3,4];case 3:r=void 0,o.label=4;case 4:return e=r,[4,this._driver.removeItem(t)];case 5:return o.sent(),n=new c({name:this.options.name,storeName:this.options.storeName,version:this.options.version,key:t,oldValue:e,newValue:null}),this._triggerEvent(n),[2]}})})},t.prototype.setItem=function(t,e){return h(this,void 0,void 0,function(){var r,n,o;return d(this,function(i){switch(i.label){case 0:return[4,this.hasItem(t)];case 1:return i.sent()?[4,this.getItem(t)]:[3,3];case 2:return n=i.sent(),[3,4];case 3:n=void 0,i.label=4;case 4:return r=n,[4,this._driver.setItem(t,e)];case 5:return i.sent(),o=new a({name:this.options.name,storeName:this.options.storeName,version:this.options.version,key:t,oldValue:r,newValue:e}),this._triggerEvent(o),[2,e]}})})},t.prototype.init=function(t){return this._initCrossTabNotification(),!!this._driver&&this._driver.init(t)},t.prototype.hasItem=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.hasItem(t)]})})},t.prototype.getDriver=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,this._driver]})})},t.prototype.destroy=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return window.removeEventListener("storage",this._storageChange),this._handlerStore.clear(),[2,this._driver.destroy()]})})},t.prototype.addEventListener=function(t){this._handlerStore.add(t)},t.prototype.removeEventListener=function(t){this._handlerStore.delete(t)},t.prototype._triggerEvent=function(t){this._applyHandlers(t),this._triggerCrossTabEvent(t)},t.prototype._triggerCrossTabEvent=function(t){this.options.crossTabNotification&&localStorage.setItem(y,u.serialize(t.copyWith({isCrossTab:!0})))},t.prototype._applyHandlers=function(t){this._handlerStore.forEach(function(e){return e(t)})},t.prototype._initCrossTabNotification=function(){window.addEventListener("storage",this._storageChange)},p([v],t.prototype,"clear",null),p([v],t.prototype,"getItem",null),p([v],t.prototype,"iterate",null),p([v],t.prototype,"key",null),p([v],t.prototype,"keys",null),p([v],t.prototype,"length",null),p([v],t.prototype,"removeItem",null),p([v],t.prototype,"setItem",null),p([v],t.prototype,"hasItem",null),p([v],t.prototype,"getDriver",null),t}();r.d(e,"EVENT_KEY",function(){return y}),r.d(e,"BrowserStorage",function(){return m}),r.d(e,"BrowserStorageEventTypes",function(){return o}),r.d(e,"BrowserStorageEvent",function(){return u}),r.d(e,"SetItemBrowserStorageEvent",function(){return a}),r.d(e,"RemoveItemBrowserStorageEvent",function(){return c}),r.d(e,"ClearBrowserStorageEvent",function(){return l})}])}); | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e);var n,o,i=(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function s(t){switch(t.type){case o.Clear:return new l(t);case o.SetItem:return new a(t);case o.RemoveItem:return new c(t);default:return new u(t)}}!function(t){t[t.Default=0]="Default",t[t.SetItem=1]="SetItem",t[t.RemoveItem=2]="RemoveItem",t[t.Clear=3]="Clear"}(o||(o={}));var u=function(){function t(t){var e=t.name,r=t.storeName,n=t.version,i=t.key,s=t.oldValue,u=t.newValue,a=t.isCrossTab,c=void 0!==a&&a;this.type=o.Default,this.name=e,this.storeName=r,this.version=n,this.key=i,this.oldValue=s,this.newValue=u,this.isCrossTab=c}return t.deserialize=function(t){return s(JSON.parse(t))},t.serialize=function(t){return JSON.stringify(t)},t.prototype.copyWith=function(t){var e=t.name,r=void 0===e?this.name:e,n=t.storeName,o=void 0===n?this.storeName:n,i=t.version,u=void 0===i?this.version:i,a=t.key,c=void 0===a?this.key:a,l=t.oldValue,f=void 0===l?this.oldValue:l,p=t.newValue,h=void 0===p?this.newValue:p,d=t.isCrossTab,v=void 0===d?this.isCrossTab:d;return s({type:this.type,name:r,storeName:o,version:u,key:c,oldValue:f,newValue:h,isCrossTab:v})},t}(),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.SetItem,e}return i(e,t),e}(u),c=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.RemoveItem,e}return i(e,t),e}(u),l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.Clear,e}return i(e,t),e}(u),f=function(){return(f=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},p=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(o=t[u])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},h=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{a(n.next(t))}catch(t){i(t)}}function u(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}a((n=n.apply(t,e||[])).next())})},d=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};function v(t,e,r){var n=r.value;r.value=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return h(this,void 0,void 0,function(){return d(this,function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[2,n.apply(this,t)]}})})}}var y="__browser_storage_event_",m=function(){function t(t){var e=this;this._handlerStore=new Set,this._storageChange=function(t){if(t.key===y){var r=localStorage.getItem(y),n=u.deserialize(r);n.name===e.options.name&&n.storeName===e.options.storeName&&e._applyHandlers(n)}},this._driver=(Array.isArray(t.drivers)?t.drivers:[t.drivers]).find(function(t){return t.isSupported}),this.options=f({},t,{drivers:void 0}),this.init(t)}return Object.defineProperty(t.prototype,"isSupported",{get:function(){return!!this._driver&&this._driver.isSupported},enumerable:!0,configurable:!0}),t.prototype.ready=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,!!this._driver&&this._driver.isSupported&&this._driver.ready()]})})},t.prototype.clear=function(){return h(this,void 0,void 0,function(){var t;return d(this,function(e){switch(e.label){case 0:return[4,this._driver.clear()];case 1:return e.sent(),t=new l({name:this.options.name,storeName:this.options.storeName,version:this.options.version,key:null,oldValue:null,newValue:null}),this._triggerEvent(t),[2]}})})},t.prototype.getItem=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.getItem(t)]})})},t.prototype.iterate=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.iterate(t)]})})},t.prototype.key=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.key(t)]})})},t.prototype.keys=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,this._driver.keys()]})})},t.prototype.length=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,this._driver.length()]})})},t.prototype.removeItem=function(t){return h(this,void 0,void 0,function(){var e,r,n;return d(this,function(o){switch(o.label){case 0:return[4,this.hasItem(t)];case 1:return o.sent()?[4,this.getItem(t)]:[3,3];case 2:return r=o.sent(),[3,4];case 3:r=void 0,o.label=4;case 4:return e=r,[4,this._driver.removeItem(t)];case 5:return o.sent(),n=new c({name:this.options.name,storeName:this.options.storeName,version:this.options.version,key:t,oldValue:e,newValue:null}),this._triggerEvent(n),[2]}})})},t.prototype.setItem=function(t,e){return h(this,void 0,void 0,function(){var r,n,o,i;return d(this,function(s){switch(s.label){case 0:return[4,this.hasItem(t)];case 1:return s.sent()?[4,this.getItem(t)]:[3,3];case 2:return n=s.sent(),[3,4];case 3:n=void 0,s.label=4;case 4:return r=n,[4,this._driver.setItem(t,e)];case 5:return o=s.sent(),i=new a({name:this.options.name,storeName:this.options.storeName,version:this.options.version,key:t,oldValue:r,newValue:e}),this._triggerEvent(i),[2,o]}})})},t.prototype.init=function(t){return this._initCrossTabNotification(),!!this._driver&&this._driver.init(t)},t.prototype.hasItem=function(t){return h(this,void 0,void 0,function(){return d(this,function(e){return[2,this._driver.hasItem(t)]})})},t.prototype.getDriver=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,this._driver]})})},t.prototype.destroy=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return window.removeEventListener("storage",this._storageChange),this._handlerStore.clear(),[2,this._driver.destroy()]})})},t.prototype.addEventListener=function(t){this._handlerStore.add(t)},t.prototype.removeEventListener=function(t){this._handlerStore.delete(t)},t.prototype._triggerEvent=function(t){this._applyHandlers(t),this._triggerCrossTabEvent(t)},t.prototype._triggerCrossTabEvent=function(t){this.options.crossTabNotification&&localStorage.setItem(y,u.serialize(t.copyWith({isCrossTab:!0})))},t.prototype._applyHandlers=function(t){this._handlerStore.forEach(function(e){return e(t)})},t.prototype._initCrossTabNotification=function(){window.addEventListener("storage",this._storageChange)},p([v],t.prototype,"clear",null),p([v],t.prototype,"getItem",null),p([v],t.prototype,"iterate",null),p([v],t.prototype,"key",null),p([v],t.prototype,"keys",null),p([v],t.prototype,"length",null),p([v],t.prototype,"removeItem",null),p([v],t.prototype,"setItem",null),p([v],t.prototype,"hasItem",null),p([v],t.prototype,"getDriver",null),t}();r.d(e,"EVENT_KEY",function(){return y}),r.d(e,"BrowserStorage",function(){return m}),r.d(e,"BrowserStorageEventTypes",function(){return o}),r.d(e,"BrowserStorageEvent",function(){return u}),r.d(e,"SetItemBrowserStorageEvent",function(){return a}),r.d(e,"RemoveItemBrowserStorageEvent",function(){return c}),r.d(e,"ClearBrowserStorageEvent",function(){return l})}])}); |
{ | ||
"name": "@browser-storage/core", | ||
"version": "0.0.1-alpha.4", | ||
"version": "0.0.1-alpha.5", | ||
"description": "Browser storage core", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "b9205a43e366e466704f3f832b607e425ffcfef7" | ||
"gitHead": "8ca146b7a42f1d399f4e61d82ded9328cdabbca7" | ||
} |
@@ -118,3 +118,3 @@ import { | ||
await this._driver.setItem<T>(key, item); | ||
const result = await this._driver.setItem<T>(key, item); | ||
@@ -132,3 +132,3 @@ const event = new SetItemBrowserStorageEvent({ | ||
return item; | ||
return result; | ||
} | ||
@@ -135,0 +135,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23701