Comparing version 1.0.0 to 1.0.1
@@ -7,2 +7,6 @@ # Changelog | ||
## [1.0.1] - 2018-12-22 | ||
### Changed | ||
- use `stores` to change store cate | ||
## [1.0.0] - 2018-12-22 | ||
@@ -9,0 +13,0 @@ ### Changed |
@@ -49,6 +49,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// import * as localForage from 'localforage'; | ||
var StorageStore_1 = require("./StorageStore"); | ||
var utils = require("./Utils/utils"); | ||
var DEFAULT_CONFIG = { | ||
stores: ['indexedDB', 'localStorage'], | ||
oldItemsCount: 0.2, | ||
@@ -60,4 +60,3 @@ }; | ||
this.cacheConfig = utils.extend(DEFAULT_CONFIG, config); | ||
var stores = ['indexedDB', 'localStorage']; | ||
this.cacheInstance = new StorageStore_1.StorageStore(stores, { | ||
this.cacheInstance = new StorageStore_1.StorageStore(this.cacheConfig.stores, { | ||
prefix: this.cacheConfig.name, | ||
@@ -64,0 +63,0 @@ }); |
@@ -160,3 +160,3 @@ "use strict"; | ||
value: true | ||
}); // import * as localForage from 'localforage'; | ||
}); | ||
@@ -168,2 +168,3 @@ var StorageStore_1 = require("./StorageStore"); | ||
var DEFAULT_CONFIG = { | ||
stores: ['indexedDB', 'localStorage'], | ||
oldItemsCount: 0.2 | ||
@@ -181,4 +182,3 @@ }; | ||
this.cacheConfig = utils.extend(DEFAULT_CONFIG, config); | ||
var stores = ['indexedDB', 'localStorage']; | ||
this.cacheInstance = new StorageStore_1.StorageStore(stores, { | ||
this.cacheInstance = new StorageStore_1.StorageStore(this.cacheConfig.stores, { | ||
prefix: this.cacheConfig.name | ||
@@ -185,0 +185,0 @@ }); |
{ | ||
"name": "mycache", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A Cache library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -46,2 +46,3 @@ # Mycache | ||
oldItemsCount: 0.2, // this count of old items | ||
stores: ['indexedDB', 'localStorage'], // use first store if system support | ||
}); | ||
@@ -48,0 +49,0 @@ ``` |
@@ -1,2 +0,1 @@ | ||
// import * as localForage from 'localforage'; | ||
import { StorageStore } from './StorageStore'; | ||
@@ -7,2 +6,3 @@ import * as typed from './typings'; | ||
const DEFAULT_CONFIG: typed.IMycacheConfig = { | ||
stores: ['indexedDB', 'localStorage'], | ||
oldItemsCount: 0.2, | ||
@@ -23,4 +23,3 @@ }; | ||
const stores = ['indexedDB', 'localStorage']; | ||
this.cacheInstance = new StorageStore(stores, { | ||
this.cacheInstance = new StorageStore(this.cacheConfig.stores, { | ||
prefix: this.cacheConfig.name, | ||
@@ -27,0 +26,0 @@ }); |
@@ -9,8 +9,5 @@ // Type definitions for Mycache | ||
export interface IMycacheConfig { | ||
driver?: string | string[]; | ||
valueMaxLength?: number; | ||
stores?: string[]; | ||
oldItemsCount?: number; | ||
name?: string; | ||
storeName?: string; | ||
isCompress?: boolean; | ||
} | ||
@@ -21,3 +18,2 @@ | ||
expire?: number; | ||
length?: number; | ||
now?: number; | ||
@@ -30,3 +26,2 @@ count?: number; | ||
expire?: number; | ||
length?: number; | ||
now?: number; | ||
@@ -33,0 +28,0 @@ value?: any; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Mycache=e():t.Mycache=e()}(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=1)}([function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return(o="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(t){return n(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)})(t)}Object.defineProperty(e,"__esModule",{value:!0});var i=Object.prototype.toString;e.isDate=function(t){return"[object Date]"===i.call(t)},e.isNumber=function(t){return"[object Number]"===i.call(t)};var s=Array.isArray;function u(t){return null!=t&&"object"===o(t)&&!1===Array.isArray(t)}function c(t){return!0===u(t)&&"[object Object]"===Object.prototype.toString.call(t)}e.isArray=s,e.isPlainObject=function(t){if(!1===c(t))return!1;var e=t.constructor;if("function"!=typeof e)return!1;var r=e.prototype;return!1!==c(r)&&!1!==r.hasOwnProperty("isPrototypeOf")},e.extend=function(t,e){if(null===e||"object"!==o(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t},e.omit=function(t,e){if(!u(t))return{};"string"==typeof e&&(e=[e]);for(var r={},n=0,o=Object.keys(t);n<o.length;n++){var i=o[n];e&&-1!==e.indexOf(i)||(r[i]=t[i])}return r}},function(t,e,r){"use strict";var n=function(){return(n=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)},o=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},i=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var s=r(2),u=r(0),c={oldItemsCount:.2},a=function(){function t(t){void 0===t&&(t={}),this.cacheConfig=u.extend(c,t);this.cacheInstance=new s.StorageStore(["indexedDB","localStorage"],{prefix:this.cacheConfig.name})}return t.prototype.getOldKeys=function(){return o(this,void 0,void 0,function(){var t,e,r,n,o,s,u,c,a;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.length()];case 1:return t=i.sent(),e=this.cacheConfig.oldItemsCount,r=e<1?Math.floor(t*e):Math.floor(e),n=[],[4,this.getSortedItems()];case 2:for(o=i.sent(),s=o.reverse(),u=0;u<s.length;u++)c=s[u],u<r&&n.push(c.key);return[2,Promise.resolve(n)];case 3:return a=i.sent(),[2,Promise.reject(a)];case 4:return[2]}})})},t.prototype.getExpiredKeys=function(){return o(this,void 0,void 0,function(){var t,e,r,n,o,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),t=[],[4,this.keys()];case 1:e=i.sent(),r=0,n=e,i.label=2;case 2:return r<n.length?(o=n[r],[4,this.isExpired(o)]):[3,5];case 3:i.sent()&&t.push(o),i.label=4;case 4:return r++,[3,2];case 5:return[2,Promise.resolve(t)];case 6:return s=i.sent(),[2,Promise.reject(s)];case 7:return[2]}})})},t.prototype.isExpired=function(t,e){return void 0===e&&(e=(new Date).getTime()),o(this,void 0,void 0,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.get(t)];case 1:return(r=o.sent())&&r.expire?[2,Promise.resolve(this.expiredVaule(r.expire,e))]:[2,Promise.resolve(!1)];case 2:return n=o.sent(),[2,Promise.reject(n)];case 3:return[2]}})})},t.prototype.get=function(t,e){return void 0===e&&(e=(new Date).getTime()),o(this,void 0,void 0,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),[4,this.cacheInstance.get(t)];case 1:return(r=o.sent())?void 0===r.expire||void 0===r.now||void 0===r.count?[3,4]:this.expiredVaule(r.expire,e)?[4,this.remove(t)]:[3,3]:[2,Promise.resolve(null)];case 2:return o.sent(),[2,Promise.resolve(null)];case 3:return[2,Promise.resolve(r.value)];case 4:return[2,Promise.resolve(r)];case 5:return n=o.sent(),[2,Promise.reject(n)];case 6:return[2]}})})},t.prototype.gets=function(t){return o(this,void 0,void 0,function(){var e,r,n,o,s,u,c;return i(this,function(i){switch(i.label){case 0:i.trys.push([0,5,,6]),e=[],r=0,n=t,i.label=1;case 1:return r<n.length?(o=n[r],u=(s=e).push,[4,this.get(o)]):[3,4];case 2:u.apply(s,[i.sent()]),i.label=3;case 3:return r++,[3,1];case 4:return[2,Promise.resolve(e)];case 5:return c=i.sent(),[2,Promise.reject(c)];case 6:return[2]}})})},t.prototype.set=function(t,e,r){return void 0===r&&(r=-1),o(this,void 0,void 0,function(){var o,s,c,a,l,f;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this.get(t)];case 1:return!(o=i.sent())||o.expire||o.count||o.now?(s=(new Date).getTime(),c=void 0,c=u.isDate(r)?r.getTime():u.isNumber(r)&&r>0?s+1e3*r:-1,a=0,o&&void 0!==o.count&&(a=o.count+1),l=void 0,l=e?{value:e,now:s,count:a,expire:c}:n({},o,{now:s,count:a}),[2,this.cacheInstance.set(t,l)]):[2,this.cacheInstance.set(t,e)];case 2:return(f=i.sent()).name.toUpperCase().indexOf("QUOTA")>=0?[4,this.clearKeys()]:[3,4];case 3:return i.sent(),[2,Promise.resolve(null)];case 4:return[2,Promise.reject(f)];case 5:return[2]}})})},t.prototype.append=function(t,e,r){return void 0===r&&(r=-1),o(this,void 0,void 0,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this.get(t)];case 1:return(n=i.sent())?(r=r||n.expire,u.isArray(e)&&u.isArray(n)?e=n.concat(e):u.isPlainObject(e)&&u.isPlainObject(n)&&(e=u.extend(n,e)),[2,this.set(t,e,r)]):[2,this.set(t,e,r)];case 2:return(o=i.sent()).name.toUpperCase().indexOf("QUOTA")>=0?[4,this.clearKeys()]:[3,4];case 3:return i.sent(),[2,Promise.resolve(null)];case 4:return[2,Promise.reject(o)];case 5:return[2]}})})},t.prototype.has=function(t){return o(this,void 0,void 0,function(){var e;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.get(t)];case 1:return r.sent()?[2,Promise.resolve(!0)]:[2,Promise.resolve(!1)];case 2:return e=r.sent(),[2,Promise.reject(e)];case 3:return[2]}})})},t.prototype.remove=function(t){return o(this,void 0,void 0,function(){var e;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.cacheInstance.remove(t)];case 1:return r.sent(),[2,Promise.resolve()];case 2:return e=r.sent(),[2,Promise.reject(e)];case 3:return[2]}})})},t.prototype.clear=function(){return o(this,void 0,void 0,function(){var t;return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.cacheInstance.clear()];case 1:return e.sent(),[2,Promise.resolve()];case 2:return t=e.sent(),[2,Promise.reject(t)];case 3:return[2]}})})},t.prototype.keys=function(){return this.cacheInstance.keys()},t.prototype.length=function(){return this.cacheInstance.length()},t.prototype.each=function(t){return o(this,void 0,void 0,function(){var e,r,n,o,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),[4,this.keys()];case 1:e=i.sent(),r=0,i.label=2;case 2:return r<e.length?(n=e[r],[4,this.get(n)]):[3,6];case 3:return o=i.sent(),t?[4,t(o,n,r)]:[3,5];case 4:i.sent(),i.label=5;case 5:return r++,[3,2];case 6:return[2,Promise.resolve(!0)];case 7:return s=i.sent(),[2,Promise.reject(s)];case 8:return[2]}})})},t.prototype.getSortedItems=function(){return o(this,void 0,void 0,function(){var t,e,r,o,s,u,c,a,l,f,h,p,y,d,v,b,w;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),[4,this.keys()];case 1:t=i.sent(),e=[],r=0,o=t,i.label=2;case 2:return r<o.length?(s=o[r],[4,this.get(s)]):[3,5];case 3:u=i.sent(),e.push(n({},u,{key:s})),i.label=4;case 4:return r++,[3,2];case 5:for(c={},a=0,l=e;a<l.length;a++)f=l[a],c[f.count]||(c[f.count]=[]),c[f.count].push(f);for(p in h=[],c)c.hasOwnProperty(p)&&h.push({count:parseInt(p,10),items:c[p].sort(function(t,e){return e.now-t.now})});for(h=h.sort(function(t,e){return e.count-t.count}),y=[],d=0,v=h;d<v.length;d++)b=v[d],y=y.concat(b.items);return[2,Promise.resolve(y)];case 6:return w=i.sent(),[2,Promise.reject(w)];case 7:return[2]}})})},t.prototype.expiredVaule=function(t,e){return t&&t>0&&t<e},t.prototype.clearKeys=function(){return o(this,void 0,void 0,function(){var t,e,r,n,o,s,u;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),[4,this.getExpiredKeys()];case 1:return t=i.sent(),r=(e=t).concat,[4,this.getOldKeys()];case 2:r.apply(e,[i.sent()]),t=t.sort().filter(function(t,e,r){return!e||t!==r[e-1]}),n=0,o=t,i.label=3;case 3:return n<o.length?(s=o[n],[4,this.remove(s)]):[3,6];case 4:i.sent(),i.label=5;case 5:return n++,[3,3];case 6:return[2,Promise.resolve(!0)];case 7:return u=i.sent(),[2,Promise.reject(u)];case 8:return[2]}})})},t}();t.exports=a},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},o=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(3),s=r(5),u=r(6),c=["indexedDB","localStorage","sessionStorage","memoryStore"],a="storage|";var l=function(){function t(t,e){void 0===t&&(t=c),void 0===e&&(e={prefix:""});var r=function(t){void 0===t&&(t=c);for(var e=s.MemoryStore,r=0,n=t;r<n.length;r++){var o=n[r];if("indexedDB"===o&&window.indexedDB){e=i.IndexedDbStore;break}if("localStorage"===o&&window.localStorage){e=u.LocalStorageStore;break}if("sessionStorage"===o&&window.sessionStorage){e=u.SessionStorageStore;break}if("memoryStore"===o){e=s.MemoryStore;break}}return e}(t);this.store=new r,this.config={prefix:e.prefix||a}}return t.prototype.get=function(t){return n(this,void 0,void 0,function(){var e;return o(this,function(r){switch(r.label){case 0:return[4,this.store.onReady()];case 1:return r.sent(),e=""+this.config.prefix+t,[2,this.store.get(e)]}})})},t.prototype.set=function(t,e){return n(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,this.store.onReady()];case 1:return r.sent(),t=""+this.config.prefix+t,[2,this.store.set(t,e)]}})})},t.prototype.remove=function(t){return n(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.store.onReady()];case 1:return e.sent(),t=""+this.config.prefix+t,[2,this.store.remove(t)]}})})},t.prototype.clear=function(){return n(this,void 0,void 0,function(){var t,e,r,n;return o(this,function(o){switch(o.label){case 0:return[4,this.store.onReady()];case 1:return o.sent(),[4,this.keys()];case 2:t=o.sent(),e=0,r=t,o.label=3;case 3:return e<r.length?(n=r[e],[4,this.remove(n)]):[3,6];case 4:o.sent(),o.label=5;case 5:return e++,[3,3];case 6:return[2,Promise.resolve(!0)]}})})},t.prototype.keys=function(){return n(this,void 0,void 0,function(){var t,e,r,n,i;return o(this,function(o){switch(o.label){case 0:return[4,this.store.onReady()];case 1:return o.sent(),[4,this.store.keys()];case 2:for(t=o.sent(),e=[],r=0,n=t;r<n.length;r++)0===(i=n[r]).indexOf(this.config.prefix)&&e.push(i.replace(this.config.prefix,""));return[2,Promise.resolve(e)]}})})},t.prototype.length=function(){return n(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.store.onReady()];case 1:return t.sent(),[2,this.store.length()]}})})},t}();e.StorageStore=l;var f=new l;e.Storage=f},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},o=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(4),s=function(){function t(){this.store=new i.IDB}return t.prototype.onReady=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.store.dbp];case 1:return e.sent(),[3,3];case 2:if("SecurityError"===(t=e.sent()).name)return[2,null];throw t;case 3:return[2,this]}})})},t.prototype.get=function(t){return n(this,void 0,void 0,function(){var e;return o(this,function(r){return[2,this.store._withIDBStore("readonly",function(r){e=r.get(t)}).then(function(){return e.result})]})})},t.prototype.set=function(t,e){return n(this,void 0,void 0,function(){return o(this,function(r){return[2,this.store._withIDBStore("readwrite",function(r){r.put(e,t)})]})})},t.prototype.remove=function(t){return n(this,void 0,void 0,function(){return o(this,function(e){return[2,this.store._withIDBStore("readwrite",function(e){e.delete(t)})]})})},t.prototype.clear=function(){return n(this,void 0,void 0,function(){return o(this,function(t){return[2,this.store._withIDBStore("readwrite",function(t){t.clear()})]})})},t.prototype.keys=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){return t=[],[2,this.store._withIDBStore("readonly",function(e){(e.openKeyCursor||e.openCursor).call(e).onsuccess=function(){this.result&&(t.push(this.result.key),this.result.continue())}}).then(function(){return t})]})})},t.prototype.length=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){return[2,this.store._withIDBStore("readwrite",function(e){t=e.count()}).then(function(){return t.result})]})})},t}();e.IndexedDbStore=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){void 0===t&&(t="mycache"),void 0===e&&(e="keyval"),this.storeName=e,this.dbp=new Promise(function(r,n){var o=indexedDB.open(t,1);o.onerror=function(){return n(o.error)},o.onsuccess=function(){return r(o.result)},o.onupgradeneeded=function(){o.result.createObjectStore(e)}})}return t.prototype._withIDBStore=function(t,e){var r=this;return this.dbp.then(function(n){return new Promise(function(o,i){var s=n.transaction(r.storeName,t);s.oncomplete=function(){return o()},s.onabort=s.onerror=function(){return i(s.error)},e(s.objectStore(r.storeName))})})},t}();e.IDB=n},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},o=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),s=function(){function t(){this.store={}}return t.prototype.onReady=function(){return n(this,void 0,void 0,function(){return o(this,function(t){return[2,this]})})},t.prototype.get=function(t){return n(this,void 0,void 0,function(){var e;return o(this,function(r){return e=this.store[t],[2,Promise.resolve(e)]})})},t.prototype.set=function(t,e){return n(this,void 0,void 0,function(){return o(this,function(r){return this.store[t]=e,[2,Promise.resolve(!0)]})})},t.prototype.remove=function(t){return n(this,void 0,void 0,function(){return o(this,function(e){return this.store[t]&&(this.store[t]=null,this.store=i.omit(this.store,t)),[2,Promise.resolve(!0)]})})},t.prototype.clear=function(){return n(this,void 0,void 0,function(){return o(this,function(t){return this.store={},[2,Promise.resolve(!0)]})})},t.prototype.keys=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){return t=Object.keys(this.store),[2,Promise.resolve(t)]})})},t.prototype.length=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return[4,this.keys()];case 1:return t=e.sent(),[2,Promise.resolve(t.length)]}})})},t}();e.MemoryStore=s},function(t,e,r){"use strict";var n,o=(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)}),i=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},s=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var u=r(7),c=function(){function t(t){this.store=t}return t.prototype.onReady=function(){return i(this,void 0,void 0,function(){return s(this,function(t){return[2,this]})})},t.prototype.get=function(t){return i(this,void 0,void 0,function(){var e,r;return s(this,function(n){return e=this.store.getItem(t),r="string"==typeof e?u.deserialize(e):void 0,[2,Promise.resolve(r)]})})},t.prototype.set=function(t,e){return i(this,void 0,void 0,function(){var r=this;return s(this,function(n){return[2,new Promise(function(n,o){u.serialize(e,function(e,i){i&&o(i);try{return r.store.setItem(t,e),n(!0)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||o(t),o(t)}})})]})})},t.prototype.remove=function(t){return i(this,void 0,void 0,function(){return s(this,function(e){return this.store.removeItem(t),[2,Promise.resolve(!0)]})})},t.prototype.clear=function(){return i(this,void 0,void 0,function(){return s(this,function(t){return this.store.clear(),[2,Promise.resolve(!0)]})})},t.prototype.keys=function(){return i(this,void 0,void 0,function(){var t,e=this;return s(this,function(r){return t=Array.apply(0,new Array(this.store.length)).map(function(t,r){return e.store.key(r)}),[2,Promise.resolve(t)]})})},t.prototype.length=function(){return i(this,void 0,void 0,function(){return s(this,function(t){return[2,Promise.resolve(this.store.length)]})})},t}(),a=function(t){function e(){return t.call(this,window.localStorage)||this}return o(e,t),e}(c);e.LocalStorageStore=a;var l=function(t){function e(){return t.call(this,window.sessionStorage)||this}return o(e,t),e}(c);e.SessionStorageStore=l},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o="~~mycache_type~",i=/^~~mycache_type~([^~]+)~/,s="__lfsc__:",u=s.length,c="arbf",a="blob",l="si08",f="ui08",h="uic8",p="si16",y="si32",d="ur16",v="ui32",b="fl32",w="fl64",g=u+c.length,m=Object.prototype.toString;function x(t){var e,r,o,i,s,u=.75*t.length,c=t.length,a=0;"="===t[t.length-1]&&(u--,"="===t[t.length-2]&&u--);var l=new ArrayBuffer(u),f=new Uint8Array(l);for(e=0;e<c;e+=4)r=n.indexOf(t[e]),o=n.indexOf(t[e+1]),i=n.indexOf(t[e+2]),s=n.indexOf(t[e+3]),f[a++]=r<<2|o>>4,f[a++]=(15&o)<<4|i>>2,f[a++]=(3&i)<<6|63&s;return l}function S(t){var e,r=new Uint8Array(t),o="";for(e=0;e<r.length;e+=3)o+=n[r[e]>>2],o+=n[(3&r[e])<<4|r[e+1]>>4],o+=n[(15&r[e+1])<<2|r[e+2]>>6],o+=n[63&r[e+2]];return r.length%3==2?o=o.substring(0,o.length-1)+"=":r.length%3==1&&(o=o.substring(0,o.length-2)+"=="),o}e.stringToBuffer=x,e.bufferToString=S,e.serialize=function(t,e){var r="";if(t&&(r=m.call(t)),t&&("[object ArrayBuffer]"===r||t.buffer&&"[object ArrayBuffer]"===m.call(t.buffer))){var n=void 0,i=s;t instanceof ArrayBuffer?(n=t,i+=c):(n=t.buffer,"[object Int8Array]"===r?i+=l:"[object Uint8Array]"===r?i+=f:"[object Uint8ClampedArray]"===r?i+=h:"[object Int16Array]"===r?i+=p:"[object Uint16Array]"===r?i+=d:"[object Int32Array]"===r?i+=y:"[object Uint32Array]"===r?i+=v:"[object Float32Array]"===r?i+=b:"[object Float64Array]"===r?i+=w:e(new Error("Failed to get type for BinaryArray"))),e(i+S(n))}else if("[object Blob]"===r){var u=new FileReader;u.onload=function(){var r=o+t.type+"~"+S(this.result);e(s+a+r)},u.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(r){console.error("Couldn't convert value into a JSON string: ",t),e(null,r)}},e.deserialize=function(t){if(t.substring(0,u)!==s)return JSON.parse(t);var e,r=t.substring(g),n=t.substring(u,g);if(n===a&&i.test(r)){var o=r.match(i);e=o[1],r=r.substring(o[0].length)}var m,S,j=x(r);switch(n){case c:return j;case a:return void 0===(m=[j])&&(m=[]),void 0===(S={type:e})&&(S={}),new Blob(m,S);case l:return new Int8Array(j);case f:return new Uint8Array(j);case h:return new Uint8ClampedArray(j);case p:return new Int16Array(j);case d:return new Uint16Array(j);case y:return new Int32Array(j);case v:return new Uint32Array(j);case b:return new Float32Array(j);case w:return new Float64Array(j);default:throw new Error("Unkown type: "+n)}}}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Mycache=e():t.Mycache=e()}(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=1)}([function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return(o="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(t){return n(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)})(t)}Object.defineProperty(e,"__esModule",{value:!0});var i=Object.prototype.toString;e.isDate=function(t){return"[object Date]"===i.call(t)},e.isNumber=function(t){return"[object Number]"===i.call(t)};var s=Array.isArray;function u(t){return null!=t&&"object"===o(t)&&!1===Array.isArray(t)}function c(t){return!0===u(t)&&"[object Object]"===Object.prototype.toString.call(t)}e.isArray=s,e.isPlainObject=function(t){if(!1===c(t))return!1;var e=t.constructor;if("function"!=typeof e)return!1;var r=e.prototype;return!1!==c(r)&&!1!==r.hasOwnProperty("isPrototypeOf")},e.extend=function(t,e){if(null===e||"object"!==o(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t},e.omit=function(t,e){if(!u(t))return{};"string"==typeof e&&(e=[e]);for(var r={},n=0,o=Object.keys(t);n<o.length;n++){var i=o[n];e&&-1!==e.indexOf(i)||(r[i]=t[i])}return r}},function(t,e,r){"use strict";var n=function(){return(n=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)},o=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},i=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var s=r(2),u=r(0),c={stores:["indexedDB","localStorage"],oldItemsCount:.2},a=function(){function t(t){void 0===t&&(t={}),this.cacheConfig=u.extend(c,t),this.cacheInstance=new s.StorageStore(this.cacheConfig.stores,{prefix:this.cacheConfig.name})}return t.prototype.getOldKeys=function(){return o(this,void 0,void 0,function(){var t,e,r,n,o,s,u,c,a;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.length()];case 1:return t=i.sent(),e=this.cacheConfig.oldItemsCount,r=e<1?Math.floor(t*e):Math.floor(e),n=[],[4,this.getSortedItems()];case 2:for(o=i.sent(),s=o.reverse(),u=0;u<s.length;u++)c=s[u],u<r&&n.push(c.key);return[2,Promise.resolve(n)];case 3:return a=i.sent(),[2,Promise.reject(a)];case 4:return[2]}})})},t.prototype.getExpiredKeys=function(){return o(this,void 0,void 0,function(){var t,e,r,n,o,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),t=[],[4,this.keys()];case 1:e=i.sent(),r=0,n=e,i.label=2;case 2:return r<n.length?(o=n[r],[4,this.isExpired(o)]):[3,5];case 3:i.sent()&&t.push(o),i.label=4;case 4:return r++,[3,2];case 5:return[2,Promise.resolve(t)];case 6:return s=i.sent(),[2,Promise.reject(s)];case 7:return[2]}})})},t.prototype.isExpired=function(t,e){return void 0===e&&(e=(new Date).getTime()),o(this,void 0,void 0,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.get(t)];case 1:return(r=o.sent())&&r.expire?[2,Promise.resolve(this.expiredVaule(r.expire,e))]:[2,Promise.resolve(!1)];case 2:return n=o.sent(),[2,Promise.reject(n)];case 3:return[2]}})})},t.prototype.get=function(t,e){return void 0===e&&(e=(new Date).getTime()),o(this,void 0,void 0,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),[4,this.cacheInstance.get(t)];case 1:return(r=o.sent())?void 0===r.expire||void 0===r.now||void 0===r.count?[3,4]:this.expiredVaule(r.expire,e)?[4,this.remove(t)]:[3,3]:[2,Promise.resolve(null)];case 2:return o.sent(),[2,Promise.resolve(null)];case 3:return[2,Promise.resolve(r.value)];case 4:return[2,Promise.resolve(r)];case 5:return n=o.sent(),[2,Promise.reject(n)];case 6:return[2]}})})},t.prototype.gets=function(t){return o(this,void 0,void 0,function(){var e,r,n,o,s,u,c;return i(this,function(i){switch(i.label){case 0:i.trys.push([0,5,,6]),e=[],r=0,n=t,i.label=1;case 1:return r<n.length?(o=n[r],u=(s=e).push,[4,this.get(o)]):[3,4];case 2:u.apply(s,[i.sent()]),i.label=3;case 3:return r++,[3,1];case 4:return[2,Promise.resolve(e)];case 5:return c=i.sent(),[2,Promise.reject(c)];case 6:return[2]}})})},t.prototype.set=function(t,e,r){return void 0===r&&(r=-1),o(this,void 0,void 0,function(){var o,s,c,a,l,f;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this.get(t)];case 1:return!(o=i.sent())||o.expire||o.count||o.now?(s=(new Date).getTime(),c=void 0,c=u.isDate(r)?r.getTime():u.isNumber(r)&&r>0?s+1e3*r:-1,a=0,o&&void 0!==o.count&&(a=o.count+1),l=void 0,l=e?{value:e,now:s,count:a,expire:c}:n({},o,{now:s,count:a}),[2,this.cacheInstance.set(t,l)]):[2,this.cacheInstance.set(t,e)];case 2:return(f=i.sent()).name.toUpperCase().indexOf("QUOTA")>=0?[4,this.clearKeys()]:[3,4];case 3:return i.sent(),[2,Promise.resolve(null)];case 4:return[2,Promise.reject(f)];case 5:return[2]}})})},t.prototype.append=function(t,e,r){return void 0===r&&(r=-1),o(this,void 0,void 0,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this.get(t)];case 1:return(n=i.sent())?(r=r||n.expire,u.isArray(e)&&u.isArray(n)?e=n.concat(e):u.isPlainObject(e)&&u.isPlainObject(n)&&(e=u.extend(n,e)),[2,this.set(t,e,r)]):[2,this.set(t,e,r)];case 2:return(o=i.sent()).name.toUpperCase().indexOf("QUOTA")>=0?[4,this.clearKeys()]:[3,4];case 3:return i.sent(),[2,Promise.resolve(null)];case 4:return[2,Promise.reject(o)];case 5:return[2]}})})},t.prototype.has=function(t){return o(this,void 0,void 0,function(){var e;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.get(t)];case 1:return r.sent()?[2,Promise.resolve(!0)]:[2,Promise.resolve(!1)];case 2:return e=r.sent(),[2,Promise.reject(e)];case 3:return[2]}})})},t.prototype.remove=function(t){return o(this,void 0,void 0,function(){var e;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.cacheInstance.remove(t)];case 1:return r.sent(),[2,Promise.resolve()];case 2:return e=r.sent(),[2,Promise.reject(e)];case 3:return[2]}})})},t.prototype.clear=function(){return o(this,void 0,void 0,function(){var t;return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.cacheInstance.clear()];case 1:return e.sent(),[2,Promise.resolve()];case 2:return t=e.sent(),[2,Promise.reject(t)];case 3:return[2]}})})},t.prototype.keys=function(){return this.cacheInstance.keys()},t.prototype.length=function(){return this.cacheInstance.length()},t.prototype.each=function(t){return o(this,void 0,void 0,function(){var e,r,n,o,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),[4,this.keys()];case 1:e=i.sent(),r=0,i.label=2;case 2:return r<e.length?(n=e[r],[4,this.get(n)]):[3,6];case 3:return o=i.sent(),t?[4,t(o,n,r)]:[3,5];case 4:i.sent(),i.label=5;case 5:return r++,[3,2];case 6:return[2,Promise.resolve(!0)];case 7:return s=i.sent(),[2,Promise.reject(s)];case 8:return[2]}})})},t.prototype.getSortedItems=function(){return o(this,void 0,void 0,function(){var t,e,r,o,s,u,c,a,l,f,h,p,y,d,v,b,w;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),[4,this.keys()];case 1:t=i.sent(),e=[],r=0,o=t,i.label=2;case 2:return r<o.length?(s=o[r],[4,this.get(s)]):[3,5];case 3:u=i.sent(),e.push(n({},u,{key:s})),i.label=4;case 4:return r++,[3,2];case 5:for(c={},a=0,l=e;a<l.length;a++)f=l[a],c[f.count]||(c[f.count]=[]),c[f.count].push(f);for(p in h=[],c)c.hasOwnProperty(p)&&h.push({count:parseInt(p,10),items:c[p].sort(function(t,e){return e.now-t.now})});for(h=h.sort(function(t,e){return e.count-t.count}),y=[],d=0,v=h;d<v.length;d++)b=v[d],y=y.concat(b.items);return[2,Promise.resolve(y)];case 6:return w=i.sent(),[2,Promise.reject(w)];case 7:return[2]}})})},t.prototype.expiredVaule=function(t,e){return t&&t>0&&t<e},t.prototype.clearKeys=function(){return o(this,void 0,void 0,function(){var t,e,r,n,o,s,u;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),[4,this.getExpiredKeys()];case 1:return t=i.sent(),r=(e=t).concat,[4,this.getOldKeys()];case 2:r.apply(e,[i.sent()]),t=t.sort().filter(function(t,e,r){return!e||t!==r[e-1]}),n=0,o=t,i.label=3;case 3:return n<o.length?(s=o[n],[4,this.remove(s)]):[3,6];case 4:i.sent(),i.label=5;case 5:return n++,[3,3];case 6:return[2,Promise.resolve(!0)];case 7:return u=i.sent(),[2,Promise.reject(u)];case 8:return[2]}})})},t}();t.exports=a},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},o=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(3),s=r(5),u=r(6),c=["indexedDB","localStorage","sessionStorage","memoryStore"],a="storage|";var l=function(){function t(t,e){void 0===t&&(t=c),void 0===e&&(e={prefix:""});var r=function(t){void 0===t&&(t=c);for(var e=s.MemoryStore,r=0,n=t;r<n.length;r++){var o=n[r];if("indexedDB"===o&&window.indexedDB){e=i.IndexedDbStore;break}if("localStorage"===o&&window.localStorage){e=u.LocalStorageStore;break}if("sessionStorage"===o&&window.sessionStorage){e=u.SessionStorageStore;break}if("memoryStore"===o){e=s.MemoryStore;break}}return e}(t);this.store=new r,this.config={prefix:e.prefix||a}}return t.prototype.get=function(t){return n(this,void 0,void 0,function(){var e;return o(this,function(r){switch(r.label){case 0:return[4,this.store.onReady()];case 1:return r.sent(),e=""+this.config.prefix+t,[2,this.store.get(e)]}})})},t.prototype.set=function(t,e){return n(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,this.store.onReady()];case 1:return r.sent(),t=""+this.config.prefix+t,[2,this.store.set(t,e)]}})})},t.prototype.remove=function(t){return n(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.store.onReady()];case 1:return e.sent(),t=""+this.config.prefix+t,[2,this.store.remove(t)]}})})},t.prototype.clear=function(){return n(this,void 0,void 0,function(){var t,e,r,n;return o(this,function(o){switch(o.label){case 0:return[4,this.store.onReady()];case 1:return o.sent(),[4,this.keys()];case 2:t=o.sent(),e=0,r=t,o.label=3;case 3:return e<r.length?(n=r[e],[4,this.remove(n)]):[3,6];case 4:o.sent(),o.label=5;case 5:return e++,[3,3];case 6:return[2,Promise.resolve(!0)]}})})},t.prototype.keys=function(){return n(this,void 0,void 0,function(){var t,e,r,n,i;return o(this,function(o){switch(o.label){case 0:return[4,this.store.onReady()];case 1:return o.sent(),[4,this.store.keys()];case 2:for(t=o.sent(),e=[],r=0,n=t;r<n.length;r++)0===(i=n[r]).indexOf(this.config.prefix)&&e.push(i.replace(this.config.prefix,""));return[2,Promise.resolve(e)]}})})},t.prototype.length=function(){return n(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.store.onReady()];case 1:return t.sent(),[2,this.store.length()]}})})},t}();e.StorageStore=l;var f=new l;e.Storage=f},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},o=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(4),s=function(){function t(){this.store=new i.IDB}return t.prototype.onReady=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.store.dbp];case 1:return e.sent(),[3,3];case 2:if("SecurityError"===(t=e.sent()).name)return[2,null];throw t;case 3:return[2,this]}})})},t.prototype.get=function(t){return n(this,void 0,void 0,function(){var e;return o(this,function(r){return[2,this.store._withIDBStore("readonly",function(r){e=r.get(t)}).then(function(){return e.result})]})})},t.prototype.set=function(t,e){return n(this,void 0,void 0,function(){return o(this,function(r){return[2,this.store._withIDBStore("readwrite",function(r){r.put(e,t)})]})})},t.prototype.remove=function(t){return n(this,void 0,void 0,function(){return o(this,function(e){return[2,this.store._withIDBStore("readwrite",function(e){e.delete(t)})]})})},t.prototype.clear=function(){return n(this,void 0,void 0,function(){return o(this,function(t){return[2,this.store._withIDBStore("readwrite",function(t){t.clear()})]})})},t.prototype.keys=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){return t=[],[2,this.store._withIDBStore("readonly",function(e){(e.openKeyCursor||e.openCursor).call(e).onsuccess=function(){this.result&&(t.push(this.result.key),this.result.continue())}}).then(function(){return t})]})})},t.prototype.length=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){return[2,this.store._withIDBStore("readwrite",function(e){t=e.count()}).then(function(){return t.result})]})})},t}();e.IndexedDbStore=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){void 0===t&&(t="mycache"),void 0===e&&(e="keyval"),this.storeName=e,this.dbp=new Promise(function(r,n){var o=indexedDB.open(t,1);o.onerror=function(){return n(o.error)},o.onsuccess=function(){return r(o.result)},o.onupgradeneeded=function(){o.result.createObjectStore(e)}})}return t.prototype._withIDBStore=function(t,e){var r=this;return this.dbp.then(function(n){return new Promise(function(o,i){var s=n.transaction(r.storeName,t);s.oncomplete=function(){return o()},s.onabort=s.onerror=function(){return i(s.error)},e(s.objectStore(r.storeName))})})},t}();e.IDB=n},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},o=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),s=function(){function t(){this.store={}}return t.prototype.onReady=function(){return n(this,void 0,void 0,function(){return o(this,function(t){return[2,this]})})},t.prototype.get=function(t){return n(this,void 0,void 0,function(){var e;return o(this,function(r){return e=this.store[t],[2,Promise.resolve(e)]})})},t.prototype.set=function(t,e){return n(this,void 0,void 0,function(){return o(this,function(r){return this.store[t]=e,[2,Promise.resolve(!0)]})})},t.prototype.remove=function(t){return n(this,void 0,void 0,function(){return o(this,function(e){return this.store[t]&&(this.store[t]=null,this.store=i.omit(this.store,t)),[2,Promise.resolve(!0)]})})},t.prototype.clear=function(){return n(this,void 0,void 0,function(){return o(this,function(t){return this.store={},[2,Promise.resolve(!0)]})})},t.prototype.keys=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){return t=Object.keys(this.store),[2,Promise.resolve(t)]})})},t.prototype.length=function(){return n(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return[4,this.keys()];case 1:return t=e.sent(),[2,Promise.resolve(t.length)]}})})},t}();e.MemoryStore=s},function(t,e,r){"use strict";var n,o=(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)}),i=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,u)}c((n=n.apply(t,e||[])).next())})},s=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])}}};Object.defineProperty(e,"__esModule",{value:!0});var u=r(7),c=function(){function t(t){this.store=t}return t.prototype.onReady=function(){return i(this,void 0,void 0,function(){return s(this,function(t){return[2,this]})})},t.prototype.get=function(t){return i(this,void 0,void 0,function(){var e,r;return s(this,function(n){return e=this.store.getItem(t),r="string"==typeof e?u.deserialize(e):void 0,[2,Promise.resolve(r)]})})},t.prototype.set=function(t,e){return i(this,void 0,void 0,function(){var r=this;return s(this,function(n){return[2,new Promise(function(n,o){u.serialize(e,function(e,i){i&&o(i);try{return r.store.setItem(t,e),n(!0)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||o(t),o(t)}})})]})})},t.prototype.remove=function(t){return i(this,void 0,void 0,function(){return s(this,function(e){return this.store.removeItem(t),[2,Promise.resolve(!0)]})})},t.prototype.clear=function(){return i(this,void 0,void 0,function(){return s(this,function(t){return this.store.clear(),[2,Promise.resolve(!0)]})})},t.prototype.keys=function(){return i(this,void 0,void 0,function(){var t,e=this;return s(this,function(r){return t=Array.apply(0,new Array(this.store.length)).map(function(t,r){return e.store.key(r)}),[2,Promise.resolve(t)]})})},t.prototype.length=function(){return i(this,void 0,void 0,function(){return s(this,function(t){return[2,Promise.resolve(this.store.length)]})})},t}(),a=function(t){function e(){return t.call(this,window.localStorage)||this}return o(e,t),e}(c);e.LocalStorageStore=a;var l=function(t){function e(){return t.call(this,window.sessionStorage)||this}return o(e,t),e}(c);e.SessionStorageStore=l},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o="~~mycache_type~",i=/^~~mycache_type~([^~]+)~/,s="__lfsc__:",u=s.length,c="arbf",a="blob",l="si08",f="ui08",h="uic8",p="si16",y="si32",d="ur16",v="ui32",b="fl32",w="fl64",g=u+c.length,m=Object.prototype.toString;function x(t){var e,r,o,i,s,u=.75*t.length,c=t.length,a=0;"="===t[t.length-1]&&(u--,"="===t[t.length-2]&&u--);var l=new ArrayBuffer(u),f=new Uint8Array(l);for(e=0;e<c;e+=4)r=n.indexOf(t[e]),o=n.indexOf(t[e+1]),i=n.indexOf(t[e+2]),s=n.indexOf(t[e+3]),f[a++]=r<<2|o>>4,f[a++]=(15&o)<<4|i>>2,f[a++]=(3&i)<<6|63&s;return l}function S(t){var e,r=new Uint8Array(t),o="";for(e=0;e<r.length;e+=3)o+=n[r[e]>>2],o+=n[(3&r[e])<<4|r[e+1]>>4],o+=n[(15&r[e+1])<<2|r[e+2]>>6],o+=n[63&r[e+2]];return r.length%3==2?o=o.substring(0,o.length-1)+"=":r.length%3==1&&(o=o.substring(0,o.length-2)+"=="),o}e.stringToBuffer=x,e.bufferToString=S,e.serialize=function(t,e){var r="";if(t&&(r=m.call(t)),t&&("[object ArrayBuffer]"===r||t.buffer&&"[object ArrayBuffer]"===m.call(t.buffer))){var n=void 0,i=s;t instanceof ArrayBuffer?(n=t,i+=c):(n=t.buffer,"[object Int8Array]"===r?i+=l:"[object Uint8Array]"===r?i+=f:"[object Uint8ClampedArray]"===r?i+=h:"[object Int16Array]"===r?i+=p:"[object Uint16Array]"===r?i+=d:"[object Int32Array]"===r?i+=y:"[object Uint32Array]"===r?i+=v:"[object Float32Array]"===r?i+=b:"[object Float64Array]"===r?i+=w:e(new Error("Failed to get type for BinaryArray"))),e(i+S(n))}else if("[object Blob]"===r){var u=new FileReader;u.onload=function(){var r=o+t.type+"~"+S(this.result);e(s+a+r)},u.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(r){console.error("Couldn't convert value into a JSON string: ",t),e(null,r)}},e.deserialize=function(t){if(t.substring(0,u)!==s)return JSON.parse(t);var e,r=t.substring(g),n=t.substring(u,g);if(n===a&&i.test(r)){var o=r.match(i);e=o[1],r=r.substring(o[0].length)}var m,S,j=x(r);switch(n){case c:return j;case a:return void 0===(m=[j])&&(m=[]),void 0===(S={type:e})&&(S={}),new Blob(m,S);case l:return new Int8Array(j);case f:return new Uint8Array(j);case h:return new Uint8ClampedArray(j);case p:return new Int16Array(j);case d:return new Uint16Array(j);case y:return new Int32Array(j);case v:return new Uint32Array(j);case b:return new Float32Array(j);case w:return new Float64Array(j);default:throw new Error("Unkown type: "+n)}}}])}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
86
0
215032
4504