Comparing version 0.1.0 to 0.2.0
@@ -7,4 +7,18 @@ # Changelog | ||
## [0.2.0] - 2018-04-18 | ||
### Added | ||
- Add `gets`, `keys`, `has` API | ||
- Add compress option | ||
### Changed | ||
- Rename `iterate` to `each` API | ||
- Rename `setItem` to `set` API | ||
- Rename `getItem` to `get` API | ||
- Rewrite `each` to support LRU | ||
### Removed | ||
- Remove `autoClear` option | ||
## [0.1.0] - 2018-04-08 | ||
### Added | ||
Init project and add all files. |
@@ -23,7 +23,7 @@ "use strict" | ||
function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function") | ||
this.state=c,this.queue=[],this.outcome=void 0,e!==o&&v(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r(function(){var r | ||
try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)})}function d(e){var t=e&&e.then | ||
if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function v(e,t){var n=!1 | ||
function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=h(function(){t(o,r)}) | ||
"error"===a.status&&r(a.value)}function h(e,t){var n={} | ||
this.state=c,this.queue=[],this.outcome=void 0,e!==o&&d(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r(function(){var r | ||
try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)})}function h(e){var t=e&&e.then | ||
if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function d(e,t){var n=!1 | ||
function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=v(function(){t(o,r)}) | ||
"error"===a.status&&r(a.value)}function v(e,t){var n={} | ||
try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===u||"function"!=typeof t&&this.state===a)return this | ||
@@ -33,6 +33,6 @@ var n=new this.constructor(o) | ||
l(n,r,this.outcome)}else this.queue.push(new f(n,e,t)) | ||
return n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=h(d,t) | ||
return n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(h,t) | ||
if("error"===n.status)return i.reject(e,n.value) | ||
var r=n.value | ||
if(r)v(e,r) | ||
if(r)d(e,r) | ||
else{e.state=u,e.outcome=t | ||
@@ -64,9 +64,9 @@ for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t | ||
var a=Promise | ||
function u(e,t){t&&e.then(function(e){t(null,e)},function(e){t(e)})}function c(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e+=""),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,v={},h=Object.prototype.toString,p="readonly",y="readwrite" | ||
function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a(function(t){var n=e.transaction(l,y),r=i([""]) | ||
function u(e,t){t&&e.then(function(e){t(null,e)},function(e){t(e)})}function c(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e+=""),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",h=void 0,d={},v=Object.prototype.toString,p="readonly",y="readwrite" | ||
function m(e){return"boolean"==typeof h?a.resolve(h):function(e){return new a(function(t){var n=e.transaction(l,y),r=i([""]) | ||
n.objectStore(l).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//) | ||
t(n||!e||parseInt(e[1],10)>=43)}}).catch(function(){return!1})}(e).then(function(e){return d=e})}function b(e){var t=v[e.name],n={} | ||
n.promise=new a(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady=t.dbReady?t.dbReady.then(function(){return n.promise}):n.promise}function g(e){var t=v[e.name],n=t.deferredOperations.pop() | ||
if(n)return n.resolve(),n.promise}function _(e,t){var n=v[e.name],r=n.deferredOperations.pop() | ||
if(r)return r.reject(t),r.promise}function I(e,t){return new a(function(n,r){if(v[e.name]=v[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db) | ||
t(n||!e||parseInt(e[1],10)>=43)}}).catch(function(){return!1})}(e).then(function(e){return h=e})}function b(e){var t=d[e.name],n={} | ||
n.promise=new a(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady=t.dbReady?t.dbReady.then(function(){return n.promise}):n.promise}function g(e){var t=d[e.name],n=t.deferredOperations.pop() | ||
if(n)return n.resolve(),n.promise}function _(e,t){var n=d[e.name],r=n.deferredOperations.pop() | ||
if(r)return r.reject(t),r.promise}function w(e,t){return new a(function(n,r){if(d[e.name]=d[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db) | ||
b(e),e.db.close()}var i=[e.name] | ||
@@ -77,8 +77,8 @@ t&&i.push(e.version) | ||
try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n | ||
console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){n(a.result),g(e)}})}function w(e){return I(e,!1)}function j(e){return I(e,!0)}function E(e,t){if(!e.db)return!0 | ||
console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){n(a.result),g(e)}})}function I(e){return w(e,!1)}function j(e){return w(e,!0)}function S(e,t){if(!e.db)return!0 | ||
var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version | ||
if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1 | ||
i>e.version&&(e.version=i)}return!0}return!1}function S(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o) | ||
i>e.version&&(e.version=i)}return!0}return!1}function E(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o) | ||
return n}(atob(e.data)) | ||
return i([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then(function(){var e=v[t._dbInfo.name] | ||
return i([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then(function(){var e=d[t._dbInfo.name] | ||
if(e&&e.dbReady)return e.dbReady}) | ||
@@ -88,13 +88,13 @@ return c(n,e,e),n}function N(e,t,n,r){void 0===r&&(r=1) | ||
n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then(function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),j(e)}).then(function(){return function(e){b(e) | ||
for(var t=v[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r] | ||
o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,w(e).then(function(t){return e.db=t,E(e)?j(e):t}).then(function(r){e.db=t.db=r | ||
for(var t=d[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r] | ||
o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,I(e).then(function(t){return e.db=t,S(e)?j(e):t}).then(function(r){e.db=t.db=r | ||
for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r}).catch(function(t){throw _(e,t),t})}(e).then(function(){N(e,t,n,r-1)})}).catch(n) | ||
n(o)}}var A={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null} | ||
n(o)}}var C={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null} | ||
if(e)for(var r in e)n[r]=e[r] | ||
var o=v[n.name] | ||
o||(v[n.name]=o={forages:[],db:null,dbReady:null,deferredOperations:[]}),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O) | ||
var o=d[n.name] | ||
o||(d[n.name]=o={forages:[],db:null,dbReady:null,deferredOperations:[]}),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O) | ||
var i=[] | ||
function u(){return a.resolve()}for(var c=0;c<o.forages.length;c++){var s=o.forages[c] | ||
s!==t&&i.push(s._initReady().catch(u))}var f=o.forages.slice(0) | ||
return a.all(i).then(function(){return n.db=o.db,w(n)}).then(function(e){return n.db=e,E(n,t._defaultConfig.version)?j(n):e}).then(function(e){n.db=o.db=e,t._dbInfo=n | ||
return a.all(i).then(function(){return n.db=o.db,I(n)}).then(function(e){return n.db=e,S(n,t._defaultConfig.version)?j(n):e}).then(function(e){n.db=o.db=e,t._dbInfo=n | ||
for(var r=0;r<f.length;r++){var i=f[r] | ||
@@ -107,3 +107,3 @@ i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}})},_support:function(){try{if(!o)return!1 | ||
if(n){var r=n.value | ||
x(r)&&(r=S(r)) | ||
x(r)&&(r=E(r)) | ||
var o=e(r,n.key,c++) | ||
@@ -116,7 +116,7 @@ void 0!==o?t(o):n.continue()}else t()},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
u.onsuccess=function(){var e=u.result | ||
void 0===e&&(e=null),x(e)&&(e=S(e)),t(e)},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
void 0===e&&(e=null),x(e)&&(e=E(e)),t(e)},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return u(r,t),r},setItem:function(e,t,n){var r=this | ||
e=s(e) | ||
var o=new a(function(n,o){var i | ||
r.ready().then(function(){return i=r._dbInfo,"[object Blob]"===h.call(t)?m(i.db).then(function(e){return e?t:(n=t,new a(function(e,t){var r=new FileReader | ||
r.ready().then(function(){return i=r._dbInfo,"[object Blob]"===v.call(t)?m(i.db).then(function(e){return e?t:(n=t,new a(function(e,t){var r=new FileReader | ||
r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"") | ||
@@ -153,3 +153,3 @@ e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})) | ||
var n,r=this.config() | ||
if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName),e.name){var i=e.name===r.name&&this._dbInfo.db,c=i?a.resolve(this._dbInfo.db):w(e).then(function(t){var n=v[e.name],r=n.forages | ||
if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName),e.name){var i=e.name===r.name&&this._dbInfo.db,c=i?a.resolve(this._dbInfo.db):I(e).then(function(t){var n=d[e.name],r=n.forages | ||
n.db=t | ||
@@ -160,3 +160,3 @@ for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t | ||
b(e) | ||
var r=v[e.name],i=r.forages | ||
var r=d[e.name],i=r.forages | ||
t.close() | ||
@@ -172,3 +172,3 @@ for(var u=0;u<i.length;u++){var c=i[u] | ||
n._dbInfo.db=e,g(n._dbInfo)}}).catch(function(t){throw(_(e,t)||a.resolve()).catch(function(){}),t})}}:function(t){b(e) | ||
var n=v[e.name],r=n.forages | ||
var n=d[e.name],r=n.forages | ||
t.close() | ||
@@ -183,17 +183,17 @@ for(var i=0;i<r.length;i++){var u=r[i] | ||
g(o._dbInfo)}}).catch(function(t){throw(_(e,t)||a.resolve()).catch(function(){}),t})})}else n=a.reject("Invalid arguments") | ||
return u(n,t),n}},D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P="~~local_forage_type~",C=/^~~local_forage_type~([^~]+)~/,R="__lfsc__:",k=R.length,T="arbf",B="blob",M="si08",L="ui08",F="uic8",z="si16",q="si32",G="ur16",U="ui32",W="fl32",K="fl64",H=k+T.length,Q=Object.prototype.toString | ||
function X(e){var t,n,r,o,i,a=.75*e.length,u=e.length,c=0 | ||
return u(n,t),n}},A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P="~~local_forage_type~",D=/^~~local_forage_type~([^~]+)~/,k="__lfsc__:",R=k.length,T="arbf",B="blob",M="si08",L="ui08",F="uic8",z="si16",q="si32",G="ur16",U="ui32",W="fl32",K="fl64",J=R+T.length,H=Object.prototype.toString | ||
function Q(e){var t,n,r,o,i,a=.75*e.length,u=e.length,c=0 | ||
"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--) | ||
var s=new ArrayBuffer(a),f=new Uint8Array(s) | ||
for(t=0;t<u;t+=4)n=D.indexOf(e[t]),r=D.indexOf(e[t+1]),o=D.indexOf(e[t+2]),i=D.indexOf(e[t+3]),f[c++]=n<<2|r>>4,f[c++]=(15&r)<<4|o>>2,f[c++]=(3&o)<<6|63&i | ||
return s}function J(e){var t,n=new Uint8Array(e),r="" | ||
for(t=0;t<n.length;t+=3)r+=D[n[t]>>2],r+=D[(3&n[t])<<4|n[t+1]>>4],r+=D[(15&n[t+1])<<2|n[t+2]>>6],r+=D[63&n[t+2]] | ||
return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var V={serialize:function(e,t){var n="" | ||
if(e&&(n=Q.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===Q.call(e.buffer))){var r,o=R | ||
e instanceof ArrayBuffer?(r=e,o+=T):(r=e.buffer,"[object Int8Array]"===n?o+=M:"[object Uint8Array]"===n?o+=L:"[object Uint8ClampedArray]"===n?o+=F:"[object Int16Array]"===n?o+=z:"[object Uint16Array]"===n?o+=G:"[object Int32Array]"===n?o+=q:"[object Uint32Array]"===n?o+=U:"[object Float32Array]"===n?o+=W:"[object Float64Array]"===n?o+=K:t(Error("Failed to get type for BinaryArray"))),t(o+J(r))}else if("[object Blob]"===n){var i=new FileReader | ||
i.onload=function(){var n=P+e.type+"~"+J(this.result) | ||
t(R+B+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,k)!==R)return JSON.parse(e) | ||
var t,n=e.substring(H),type=e.substring(k,H) | ||
if(type===B&&C.test(n)){var r=n.match(C) | ||
t=r[1],n=n.substring(r[0].length)}var o=X(n) | ||
for(t=0;t<u;t+=4)n=A.indexOf(e[t]),r=A.indexOf(e[t+1]),o=A.indexOf(e[t+2]),i=A.indexOf(e[t+3]),f[c++]=n<<2|r>>4,f[c++]=(15&r)<<4|o>>2,f[c++]=(3&o)<<6|63&i | ||
return s}function X(e){var t,n=new Uint8Array(e),r="" | ||
for(t=0;t<n.length;t+=3)r+=A[n[t]>>2],r+=A[(3&n[t])<<4|n[t+1]>>4],r+=A[(15&n[t+1])<<2|n[t+2]>>6],r+=A[63&n[t+2]] | ||
return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var Z={serialize:function(e,t){var n="" | ||
if(e&&(n=H.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===H.call(e.buffer))){var r,o=k | ||
e instanceof ArrayBuffer?(r=e,o+=T):(r=e.buffer,"[object Int8Array]"===n?o+=M:"[object Uint8Array]"===n?o+=L:"[object Uint8ClampedArray]"===n?o+=F:"[object Int16Array]"===n?o+=z:"[object Uint16Array]"===n?o+=G:"[object Int32Array]"===n?o+=q:"[object Uint32Array]"===n?o+=U:"[object Float32Array]"===n?o+=W:"[object Float64Array]"===n?o+=K:t(Error("Failed to get type for BinaryArray"))),t(o+X(r))}else if("[object Blob]"===n){var i=new FileReader | ||
i.onload=function(){var n=P+e.type+"~"+X(this.result) | ||
t(k+B+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,R)!==k)return JSON.parse(e) | ||
var t,n=e.substring(J),type=e.substring(R,J) | ||
if(type===B&&D.test(n)){var r=n.match(D) | ||
t=r[1],n=n.substring(r[0].length)}var o=Q(n) | ||
switch(type){case T:return o | ||
@@ -210,8 +210,8 @@ case B:return i([o],{type:t}) | ||
case K:return new Float64Array(o) | ||
default:throw Error("Unkown type: "+type)}},stringToBuffer:X,bufferToString:J} | ||
function Y(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function Z(e,t,n,r,o,i){e.executeSql(n,r,o,function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[name],function(e,u){u.rows.length?i(e,a):Y(e,t,function(){e.executeSql(n,r,o,i)},i)},i):i(e,a)},i)}var $={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null} | ||
default:throw Error("Unkown type: "+type)}},stringToBuffer:Q,bufferToString:X} | ||
function V(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function Y(e,t,n,r,o,i){e.executeSql(n,r,o,function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[name],function(e,u){u.rows.length?i(e,a):V(e,t,function(){e.executeSql(n,r,o,i)},i)},i):i(e,a)},i)}var $={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null} | ||
if(e)for(var r in e)n[r]="string"!=typeof e[r]?""+e[r]:e[r] | ||
var o=new a(function(e,r){try{n.db=openDatabase(n.name,n.version+"",n.description,n.size)}catch(e){return r(e)}n.db.transaction(function(o){Y(o,n,function(){t._dbInfo=n,e()},function(e,t){r(t)})},r)}) | ||
return n.serializer=V,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT * FROM "+o.storeName,[],function(n,r){for(var i=r.rows,a=i.length,u=0;u<a;u++){var c=i.item(u),s=c.value | ||
var o=new a(function(e,r){try{n.db=openDatabase(n.name,n.version+"",n.description,n.size)}catch(e){return r(e)}n.db.transaction(function(o){V(o,n,function(){t._dbInfo=n,e()},function(e,t){r(t)})},r)}) | ||
return n.serializer=Z,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Y(n,o,"SELECT * FROM "+o.storeName,[],function(n,r){for(var i=r.rows,a=i.length,u=0;u<a;u++){var c=i.item(u),s=c.value | ||
if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,c.key,u+1)))return void t(s)}t()},function(e,t){r(t)})})}).catch(r)}) | ||
@@ -221,3 +221,3 @@ return u(r,t),r},getItem:function(e,t){var n=this | ||
var r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],function(e,n){var r=n.rows.length?n.rows.item(0).value:null | ||
o.db.transaction(function(n){Y(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],function(e,n){var r=n.rows.length?n.rows.item(0).value:null | ||
r&&(r=o.serializer.deserialize(r)),t(r)},function(e,t){r(t)})})}).catch(r)}) | ||
@@ -228,3 +228,3 @@ return u(r,t),r},setItem:function(e,t,n){return function e(t,n,r,o){var i=this | ||
var c=n,s=i._dbInfo | ||
s.serializer.serialize(n,function(n,f){f?u(f):s.db.transaction(function(e){Z(e,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[t,n],function(){a(c)},function(e,t){u(t)})},function(n){if(n.code===n.QUOTA_ERR){if(o>0)return void a(e.call(i,t,c,r,o-1)) | ||
s.serializer.serialize(n,function(n,f){f?u(f):s.db.transaction(function(e){Y(e,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[t,n],function(){a(c)},function(e,t){u(t)})},function(n){if(n.code===n.QUOTA_ERR){if(o>0)return void a(e.call(i,t,c,r,o-1)) | ||
u(n)}})})}).catch(u)}) | ||
@@ -234,13 +234,13 @@ return u(c,r),c}.call(this,e,t,n,1)},removeItem:function(e,t){var n=this | ||
var r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){r(t)})})}).catch(r)}) | ||
o.db.transaction(function(n){Y(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){r(t)})})}).catch(r)}) | ||
return u(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"DELETE FROM "+r.storeName,[],function(){e()},function(e,t){n(t)})})}).catch(n)}) | ||
r.db.transaction(function(t){Y(t,r,"DELETE FROM "+r.storeName,[],function(){e()},function(e,t){n(t)})})}).catch(n)}) | ||
return u(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],function(t,n){var r=n.rows.item(0).c | ||
r.db.transaction(function(t){Y(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],function(t,n){var r=n.rows.item(0).c | ||
e(r)},function(e,t){n(t)})})}).catch(n)}) | ||
return u(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,n){var r=n.rows.length?n.rows.item(0).key:null | ||
o.db.transaction(function(n){Y(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,n){var r=n.rows.length?n.rows.item(0).key:null | ||
t(r)},function(e,t){r(t)})})}).catch(r)}) | ||
return u(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"SELECT key FROM "+r.storeName,[],function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key) | ||
r.db.transaction(function(t){Y(t,r,"SELECT key FROM "+r.storeName,[],function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key) | ||
e(r)},function(e,t){n(t)})})}).catch(n)}) | ||
@@ -257,3 +257,3 @@ return u(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments) | ||
if(e)for(var n in e)t[n]=e[n] | ||
return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=V,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then(function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,u=0;u<i;u++){var c=localStorage.key(u) | ||
return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=Z,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then(function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,u=0;u<i;u++){var c=localStorage.key(u) | ||
if(0===c.indexOf(r)){var s=localStorage.getItem(c) | ||
@@ -288,7 +288,7 @@ if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,c.substring(o),a++)))return s}}}) | ||
r++}var o,i | ||
return!1},oe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},ue={INDEXEDDB:A,WEBSQL:$,LOCALSTORAGE:ne},ce=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],se=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),le={description:"",driver:ce.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1} | ||
function de(e,t){e[t]=function(){var n=arguments | ||
return e.ready().then(function(){return e[t].apply(e,n)})}}function ve(){for(var e=1;e<arguments.length;e++){var t=arguments[e] | ||
if(t)for(var n in t)t.hasOwnProperty(n)&&(arguments[0][n]=oe(t[n])?t[n].slice():t[n])}return arguments[0]}var he=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver | ||
this[n]=o,ie[o]||this.defineDriver(r)}this._defaultConfig=ve({},le),this._config=ve({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return Error("Can't call config() after localforage has been used.") | ||
return!1},oe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},ue={INDEXEDDB:C,WEBSQL:$,LOCALSTORAGE:ne},ce=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],se=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),le={description:"",driver:ce.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1} | ||
function he(e,t){e[t]=function(){var n=arguments | ||
return e.ready().then(function(){return e[t].apply(e,n)})}}function de(){for(var e=1;e<arguments.length;e++){var t=arguments[e] | ||
if(t)for(var n in t)t.hasOwnProperty(n)&&(arguments[0][n]=oe(t[n])?t[n].slice():t[n])}return arguments[0]}var ve=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver | ||
this[n]=o,ie[o]||this.defineDriver(r)}this._defaultConfig=de({},le),this._config=de({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return Error("Can't call config() after localforage has been used.") | ||
for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return Error("Database version must be a number.") | ||
@@ -301,6 +301,6 @@ this._config[t]=e[t]}return!("driver"in e&&e.driver)||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new a(function(t,n){try{var r=e._driver,o=Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver") | ||
e[o]||(e[o]=t(o))}}() | ||
var d=function(n){ie[r]&&console.info("Redefining LocalForage driver: "+r),ie[r]=e,ae[r]=n,t()} | ||
"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}) | ||
var h=function(n){ie[r]&&console.info("Redefining LocalForage driver: "+r),ie[r]=e,ae[r]=n,t()} | ||
"_support"in e?e._support&&"function"==typeof e._support?e._support().then(h,n):h(!!e._support):h(!0)}catch(e){n(e)}}) | ||
return c(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ie[e]?a.resolve(ie[e]):a.reject(Error("Driver not found.")) | ||
return c(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(V) | ||
return c(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(Z) | ||
return c(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then(function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}) | ||
@@ -318,4 +318,4 @@ return c(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this | ||
var e=Error("No available storage method found.") | ||
return r._driverSet=a.reject(e),r._driverSet}),c(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){ve(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n] | ||
this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)de(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new he | ||
return r._driverSet=a.reject(e),r._driverSet}),c(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){de(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n] | ||
this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)he(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new ve | ||
t.exports=pe},{3:3}]},{},[4])(4)}),utils=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}) | ||
@@ -331,3 +331,29 @@ var n=Object.prototype.toString | ||
unwrapExports(utils) | ||
var utils_1=utils.isDate,utils_2=utils.isNumber,utils_3=utils.isArray,utils_4=utils.isPlainObject,utils_5=utils.extend,utils_6=utils.omit,Persist_1=createCommonjsModule(function(e,t){var n=commonjsGlobal&&commonjsGlobal.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},r=commonjsGlobal&&commonjsGlobal.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
var utils_1=utils.isDate,utils_2=utils.isNumber,utils_3=utils.isArray,utils_4=utils.isPlainObject,utils_5=utils.extend,utils_6=utils.omit,LZString_1=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}) | ||
var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),o=0,i={},a=r.concat() | ||
for(a[63]="-",a[64]="$";o<65;)o>62&&(i[a[o].charCodeAt(0)]=o),i[r[o].charCodeAt(0)]=o++ | ||
var u=function(e){return{v:e,d:{}}},c=function(e,t,r){for(var o=["","",""],i=4,a=4,u=3,c="",s=[],f=0,l=2,h=0,d="",v=r(0),p=t,y=1;h!==l;)f+=(v>>--p&1)<<h++,0==p&&(p=t,v=r(y++)) | ||
if(2===f)return"" | ||
for(l=8*f+8,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
for(d=n(f),o[3]=d,s.push(d);y<=e;){for(l=u,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
if(f<2){for(l=8+8*f,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
o[a]=n(f),f=a++,0==--i&&(i=1<<u++)}else if(2==f)return s.join("") | ||
if(f>o.length)return null | ||
c=f<o.length?o[f]:d+d.charAt(0),s.push(c),o[a++]=d+c.charAt(0),d=c,0==--i&&(i=1<<u++)}return""},s=function(e){return function(e,t,n){if(null==e)return[] | ||
var r,o=0,i=0,a=0,c=new Map,s=!0,f=0,l=u(3),h=1,d=4,v=2,p=[],y=0,m=0 | ||
if(e.length){for(a=(f=e.charCodeAt(0))<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(c.set(f,l),i=1;i<e.length;i++)if(f=e.charCodeAt(i),r=l.d[f])l=r | ||
else{if(s)s=!1 | ||
else for(a=l.v,o=0;o<v;o++)y=a>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
if(!c.has(f)){for(0==--h&&(h=1<<v++),a=f<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++m==t&&(m=0,p.push(n(y)),y=0) | ||
c.set(f,u(d++)),s=!0}l.d[f]=u(d++),0==--h&&(h=1<<v++),l=c.get(f)}if(s)s=!1 | ||
else for(a=l.v,o=0;o<v;o++)y=a>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
if(!c.has(f)){for(0==--h&&(h=1<<v++),a=f<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0)}0==--h&&(h=1<<v++)}for(o=0;o<v;o++)y=2>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
return p.push(n(y<<=t-m)),p}(e,16,function(e){return n(e)})} | ||
t.default={compress:function(e){return s(e).join("")},compressToArray:s,decompress:function(e){return null===e?"":""===e?null:c(e.length,16,function(t){return e.charCodeAt(t)})},decompressFromArray:function(e){return null===e?"":0===e.length?null:c(e.length,16,function(t){return e[t].charCodeAt(0)})}}}) | ||
unwrapExports(LZString_1) | ||
var Persist_1=createCommonjsModule(function(e,t){var n=commonjsGlobal&&commonjsGlobal.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},r=commonjsGlobal&&commonjsGlobal.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
return o[1]},trys:[],ops:[]} | ||
@@ -352,17 +378,35 @@ return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i | ||
Object.defineProperty(t,"__esModule",{value:!0}) | ||
var o={driver:[localforage.INDEXEDDB,localforage.LOCALSTORAGE],valueMaxLength:5e5,autoClearExpires:!1},i=function(){function e(e){void 0===e&&(e={}) | ||
var t=this | ||
this.cacheConfig=utils.extend(e,o),this.cacheInstance=localforage.createInstance(this.cacheConfig),this.cacheConfig.autoClearExpires&&(window.onbeforeunload=function(e){t.clearExpires()})}return e.prototype.clearExpires=function(){var e=this | ||
return this.cacheInstance.iterate(function(t,n){Promise.all([e.isExpired(t),e.isOverLength(t)]).then(function(t){(t[0]||t[1])&&e.cacheInstance.removeItem(n)})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.isOverLength=function(e){return n(this,void 0,void 0,function(){var t,n | ||
var o={driver:[localforage.INDEXEDDB,localforage.LOCALSTORAGE],valueMaxLength:5e5,isCompress:!1},i=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=utils.extend(e,o),this.cacheInstance=localforage.createInstance(this.cacheConfig)}return e.prototype.autoClear=function(){var e=this | ||
return this.cacheInstance.iterate(function(t,n){Promise.all([e.isExpired(t),e.isOverLength(t)]).then(function(t){(t[0]||t[1])&&e.remove(n)})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.isOverLength=function(e){return n(this,void 0,void 0,function(){var t,n | ||
return r(this,function(r){switch(r.label){case 0:return t=this.cacheConfig.valueMaxLength,[4,this.cacheInstance.getSerializer()] | ||
case 1:return n=r.sent(),[2,new Promise(function(r,o){n.serialize(e,function(e,n){n&&o(n),r(e.lenth>(t||0))})})]}})})},e.prototype.dropInstance=function(e){return void 0===e&&(e={}),this.cacheInstance.dropInstance(e)},e.prototype.getItem=function(e){return n(this,void 0,void 0,function(){var t,n,o | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.cacheInstance.getItem(e)] | ||
case 1:return n=r.sent(),[2,new Promise(function(r,o){n.serialize(e,function(e,n){n&&o(n),r(e.lenth>(t||0))})})]}})})},e.prototype.dropInstance=function(e){return void 0===e&&(e={}),this.cacheInstance.dropInstance(e)},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),[4,this.getItem(e)] | ||
case 1:return t=r.sent(),[4,this.isExpired(t)] | ||
case 2:return n=r.sent(),t&&t.value?n?(this.cacheInstance.removeItem(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[3,4]:[2,Promise.resolve(null)] | ||
case 3:return o=r.sent(),[2,Promise.reject(o)] | ||
case 4:return[2]}})})},e.prototype.setItem=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){return r(this,function(n){return utils.isDate(o)?o=o.getTime():utils.isNumber(o)&&o>0&&(o=(new Date).getTime()+1e3*o),[2,this.cacheInstance.setItem(e,{value:t,expire:o})]})})},e.prototype.appendItem=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){var n,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.cacheInstance.getItem(e)] | ||
case 2:return n=r.sent(),t&&t.value?[3,3]:[2,Promise.resolve(null)] | ||
case 3:return n?(this.remove(e),[2,Promise.resolve(null)]):[3,4] | ||
case 4:return t.value?(o=t.value,this.cacheConfig.isCompress&&(o=JSON.parse(LZString_1.default.decompress(t.value))),[4,this.set(e,t.value,t.expire)]):[3,6] | ||
case 5:return r.sent(),[2,Promise.resolve(o)] | ||
case 6:return[3,8] | ||
case 7:return i=r.sent(),[2,Promise.reject(i)] | ||
case 8:return[2]}})})},e.prototype.gets=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:t=[],n=0,r.label=1 | ||
case 1:return n<e.length?(i=(o=t).push,[4,this.get(e[n])]):[3,4] | ||
case 2:i.call(o,r.sent()),r.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(t)]}})})},e.prototype.set=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){var n,i,a,u | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.cacheInstance.getSerializer()] | ||
case 1:return r.sent(),n=(new Date).getTime(),utils.isDate(o)?o=o.getTime():utils.isNumber(o)&&o>0&&(o=n+1e3*o),[4,this.setItem(e,{value:this.cacheConfig.isCompress?LZString_1.default.compress(JSON.stringify(t)):t,expire:o,now:n})] | ||
case 2:return i=r.sent(),a=this.cacheConfig.isCompress?JSON.parse(LZString_1.default.decompress(i.value)):i.value,[2,Promise.resolve(a)] | ||
case 3:return u=r.sent(),[2,Promise.reject(u)] | ||
case 4:return[2]}})})},e.prototype.append=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){var n,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getItem(e)] | ||
case 1:return n=r.sent(),[3,3] | ||
case 2:return i=r.sent(),[2,Promise.reject(i)] | ||
case 3:return n?(utils.isArray(t)&&utils.isArray(n.value)?t=n.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(n.value)&&(t=utils.extend(n.value,t)),[2,this.setItem(e,t,o=o||n.expire)]):[2,this.setItem(e,t,o)]}})})},e.prototype.removeItem=function(e){return this.cacheInstance.removeItem(e)},e.prototype.clear=function(){return this.cacheInstance.clear()},e.prototype.length=function(){return this.cacheInstance.length()},e.prototype.iterate=function(e,t){return void 0===t&&(t=null),this.cacheInstance.iterate(e,t)},e}() | ||
case 3:return n?(utils.isArray(t)&&utils.isArray(n.value)?t=n.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(n.value)&&(t=utils.extend(n.value,t)),[2,this.set(e,t,o=o||n.expire)]):[2,this.set(e,t,o)]}})})},e.prototype.has=function(e){return n(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,this.get(e)] | ||
case 1:return t.sent()?[2,Promise.resolve(!0)]:[2,Promise.resolve(!1)]}})})},e.prototype.remove=function(e){return this.cacheInstance.removeItem(e)},e.prototype.keys=function(){return this.cacheInstance.keys()},e.prototype.clear=function(){return this.cacheInstance.clear()},e.prototype.length=function(){return this.cacheInstance.length()},e.prototype.each=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=[],[4,this.cacheInstance.iterate(function(e,n,r){t.push({key:n,value:e})})] | ||
case 1:for(r.sent(),n=t.sort(function(e,t){return e.value.now-e.value.now}),o=0;o<n.length;o++)e&&e(n[o].value.value,n[o].key,o) | ||
return[2,Promise.resolve(!0)] | ||
case 2:return i=r.sent(),[2,Promise.reject(i)] | ||
case 3:return[2]}})})},e.prototype.getItem=function(e){return this.cacheInstance.getItem(e)},e.prototype.setItem=function(e,t){return n(this,void 0,void 0,function(){return r(this,function(n){return[2,this.cacheInstance.setItem(e,t)]})})},e}() | ||
t.default=i}) | ||
@@ -390,14 +434,21 @@ unwrapExports(Persist_1) | ||
Object.defineProperty(t,"__esModule",{value:!0}) | ||
var o=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=utils.extend(e,{name:"memcache"}),this.cacheInstance={}}return e.prototype.clearExpires=function(){return n(this,void 0,void 0,function(){var e=this | ||
var o=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=utils.extend(e,{name:"memcache"}),this.cacheInstance={}}return e.prototype.autoClear=function(){return n(this,void 0,void 0,function(){var e=this | ||
return r(this,function(t){return Object.keys(this.cacheInstance).forEach(function(t,o){return n(e,void 0,void 0,function(){var e,n | ||
return r(this,function(r){switch(r.label){case 0:return e=this.cacheInstance[t],n=t.replace(this.cacheConfig.name+"/",""),[4,this.isExpired(e)] | ||
case 1:return r.sent()&&this.removeItem(n),[2]}})})}),[2,Promise.resolve(!0)]})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.getKey=function(e){return this.cacheConfig.name+"/"+e},e.prototype.getItem=function(e){return n(this,void 0,void 0,function(){var t,n | ||
case 1:return r.sent()&&this.remove(n),[2]}})})}),[2,Promise.resolve(!0)]})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.getKey=function(e){return this.cacheConfig.name+"/"+e},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t,n | ||
return r(this,function(r){switch(r.label){case 0:return e=this.getKey(e),[4,this.isExpired(t=this.cacheInstance[e])] | ||
case 1:return n=r.sent(),t&&t.value?n?(this.removeItem(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[2]:[2,Promise.resolve(null)]}})})},e.prototype.setItem=function(e,t,n){return void 0===n&&(n=-1),e=this.getKey(e),utils.isDate(n)?n=n.getTime():utils.isNumber(n)&&n>0&&(n=(new Date).getTime()+1e3*n),this.cacheInstance[e]={value:t,expire:n},Promise.resolve(t)},e.prototype.appendItem=function(e,t,n){void 0===n&&(n=-1) | ||
case 1:return n=r.sent(),t&&t.value?n?(this.remove(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[2]:[2,Promise.resolve(null)]}})})},e.prototype.gets=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:t=[],n=0,r.label=1 | ||
case 1:return n<e.length?(i=(o=t).push,[4,this.get(e[n])]):[3,4] | ||
case 2:i.call(o,r.sent()),r.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(t)]}})})},e.prototype.set=function(e,t,n){return void 0===n&&(n=-1),e=this.getKey(e),utils.isDate(n)?n=n.getTime():utils.isNumber(n)&&n>0&&(n=(new Date).getTime()+1e3*n),this.cacheInstance[e]={value:t,expire:n},Promise.resolve(t)},e.prototype.append=function(e,t,n){void 0===n&&(n=-1) | ||
var r=this.cacheInstance[this.getKey(e)] | ||
return r?(utils.isArray(t)&&utils.isArray(r.value)?t=r.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(r.value)&&(t=utils.extend(r.value,t)),this.setItem(e,t,n=n||r.expire)):this.setItem(e,t,n)},e.prototype.removeItem=function(e){return e=this.getKey(e),this.cacheInstance[e]&&(this.cacheInstance[e]=null,this.cacheInstance=utils.omit(this.cacheInstance,e)),Promise.resolve()},e.prototype.clear=function(){return this.cacheInstance={},Promise.resolve()},e.prototype.length=function(){var e=Object.keys(this.cacheInstance) | ||
return e.length?Promise.resolve(e.length):Promise.resolve(0)},e.prototype.iterate=function(e,t){return void 0===t&&(t=null),n(this,void 0,void 0,function(){var o,i,a=this | ||
return r(this,function(u){return i=(o=Object.keys(this.cacheInstance)).length>0?this.cacheInstance[o[o.length-1]].value:null,o.forEach(function(t,o){return n(a,void 0,void 0,function(){var n | ||
return r(this,function(r){switch(r.label){case 0:return t=t.replace(this.cacheConfig.name+"/",""),[4,this.getItem(t)] | ||
case 1:return n=r.sent(),e(n,t,o),[2]}})})}),t&&t(null,i),[2,Promise.resolve(i)]})})},e}() | ||
return r?(utils.isArray(t)&&utils.isArray(r.value)?t=r.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(r.value)&&(t=utils.extend(r.value,t)),this.set(e,t,n=n||r.expire)):this.set(e,t,n)},e.prototype.has=function(e){return this.get(e)?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.remove=function(e){return e=this.getKey(e),this.cacheInstance[e]&&(this.cacheInstance[e]=null,this.cacheInstance=utils.omit(this.cacheInstance,e)),Promise.resolve()},e.prototype.keys=function(){return Promise.resolve(Object.keys(this.cacheInstance))},e.prototype.clear=function(){return this.cacheInstance={},Promise.resolve()},e.prototype.length=function(){var e=Object.keys(this.cacheInstance) | ||
return e.length?Promise.resolve(e.length):Promise.resolve(0)},e.prototype.each=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:t=Object.keys(this.cacheInstance),n=0,r.label=1 | ||
case 1:return n<t.length?(o=t[n].replace(this.cacheConfig.name+"/",""),[4,this.get(o)]):[3,4] | ||
case 2:i=r.sent(),e&&e(i,o,n),r.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(!0)]}})})},e}() | ||
t.default=o}) | ||
@@ -404,0 +455,0 @@ unwrapExports(Cache_1) |
@@ -21,7 +21,7 @@ var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{} | ||
function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function") | ||
this.state=c,this.queue=[],this.outcome=void 0,e!==o&&v(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r(function(){var r | ||
try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)})}function d(e){var t=e&&e.then | ||
if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function v(e,t){var n=!1 | ||
function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=h(function(){t(o,r)}) | ||
"error"===a.status&&r(a.value)}function h(e,t){var n={} | ||
this.state=c,this.queue=[],this.outcome=void 0,e!==o&&d(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r(function(){var r | ||
try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)})}function h(e){var t=e&&e.then | ||
if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function d(e,t){var n=!1 | ||
function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=v(function(){t(o,r)}) | ||
"error"===a.status&&r(a.value)}function v(e,t){var n={} | ||
try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===u||"function"!=typeof t&&this.state===a)return this | ||
@@ -31,6 +31,6 @@ var n=new this.constructor(o) | ||
l(n,r,this.outcome)}else this.queue.push(new f(n,e,t)) | ||
return n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=h(d,t) | ||
return n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(h,t) | ||
if("error"===n.status)return i.reject(e,n.value) | ||
var r=n.value | ||
if(r)v(e,r) | ||
if(r)d(e,r) | ||
else{e.state=u,e.outcome=t | ||
@@ -62,9 +62,9 @@ for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t | ||
var a=Promise | ||
function u(e,t){t&&e.then(function(e){t(null,e)},function(e){t(e)})}function c(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e+=""),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,v={},h=Object.prototype.toString,p="readonly",y="readwrite" | ||
function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a(function(t){var n=e.transaction(l,y),r=i([""]) | ||
function u(e,t){t&&e.then(function(e){t(null,e)},function(e){t(e)})}function c(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e+=""),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",h=void 0,d={},v=Object.prototype.toString,p="readonly",y="readwrite" | ||
function m(e){return"boolean"==typeof h?a.resolve(h):function(e){return new a(function(t){var n=e.transaction(l,y),r=i([""]) | ||
n.objectStore(l).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//) | ||
t(n||!e||parseInt(e[1],10)>=43)}}).catch(function(){return!1})}(e).then(function(e){return d=e})}function b(e){var t=v[e.name],n={} | ||
n.promise=new a(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady=t.dbReady?t.dbReady.then(function(){return n.promise}):n.promise}function g(e){var t=v[e.name],n=t.deferredOperations.pop() | ||
if(n)return n.resolve(),n.promise}function _(e,t){var n=v[e.name],r=n.deferredOperations.pop() | ||
if(r)return r.reject(t),r.promise}function I(e,t){return new a(function(n,r){if(v[e.name]=v[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db) | ||
t(n||!e||parseInt(e[1],10)>=43)}}).catch(function(){return!1})}(e).then(function(e){return h=e})}function b(e){var t=d[e.name],n={} | ||
n.promise=new a(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady=t.dbReady?t.dbReady.then(function(){return n.promise}):n.promise}function g(e){var t=d[e.name],n=t.deferredOperations.pop() | ||
if(n)return n.resolve(),n.promise}function _(e,t){var n=d[e.name],r=n.deferredOperations.pop() | ||
if(r)return r.reject(t),r.promise}function w(e,t){return new a(function(n,r){if(d[e.name]=d[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db) | ||
b(e),e.db.close()}var i=[e.name] | ||
@@ -75,31 +75,31 @@ t&&i.push(e.version) | ||
try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n | ||
console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){n(a.result),g(e)}})}function w(e){return I(e,!1)}function j(e){return I(e,!0)}function E(e,t){if(!e.db)return!0 | ||
console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){n(a.result),g(e)}})}function I(e){return w(e,!1)}function j(e){return w(e,!0)}function S(e,t){if(!e.db)return!0 | ||
var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version | ||
if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1 | ||
i>e.version&&(e.version=i)}return!0}return!1}function S(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o) | ||
i>e.version&&(e.version=i)}return!0}return!1}function E(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o) | ||
return n}(atob(e.data)) | ||
return i([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function N(e){var t=this,n=t._initReady().then(function(){var e=v[t._dbInfo.name] | ||
return i([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then(function(){var e=d[t._dbInfo.name] | ||
if(e&&e.dbReady)return e.dbReady}) | ||
return c(n,e,e),n}function O(e,t,n,r){void 0===r&&(r=1) | ||
return c(n,e,e),n}function N(e,t,n,r){void 0===r&&(r=1) | ||
try{var o=e.db.transaction(e.storeName,t) | ||
n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then(function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),j(e)}).then(function(){return function(e){b(e) | ||
for(var t=v[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r] | ||
o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,w(e).then(function(t){return e.db=t,E(e)?j(e):t}).then(function(r){e.db=t.db=r | ||
for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r}).catch(function(t){throw _(e,t),t})}(e).then(function(){O(e,t,n,r-1)})}).catch(n) | ||
n(o)}}var A={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null} | ||
for(var t=d[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r] | ||
o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,I(e).then(function(t){return e.db=t,S(e)?j(e):t}).then(function(r){e.db=t.db=r | ||
for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r}).catch(function(t){throw _(e,t),t})}(e).then(function(){N(e,t,n,r-1)})}).catch(n) | ||
n(o)}}var C={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null} | ||
if(e)for(var r in e)n[r]=e[r] | ||
var o=v[n.name] | ||
o||(v[n.name]=o={forages:[],db:null,dbReady:null,deferredOperations:[]}),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=N) | ||
var o=d[n.name] | ||
o||(d[n.name]=o={forages:[],db:null,dbReady:null,deferredOperations:[]}),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O) | ||
var i=[] | ||
function u(){return a.resolve()}for(var c=0;c<o.forages.length;c++){var s=o.forages[c] | ||
s!==t&&i.push(s._initReady().catch(u))}var f=o.forages.slice(0) | ||
return a.all(i).then(function(){return n.db=o.db,w(n)}).then(function(e){return n.db=e,E(n,t._defaultConfig.version)?j(n):e}).then(function(e){n.db=o.db=e,t._dbInfo=n | ||
return a.all(i).then(function(){return n.db=o.db,I(n)}).then(function(e){return n.db=e,S(n,t._defaultConfig.version)?j(n):e}).then(function(e){n.db=o.db=e,t._dbInfo=n | ||
for(var r=0;r<f.length;r++){var i=f[r] | ||
i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}})},_support:function(){try{if(!o)return!1 | ||
var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==(""+fetch).indexOf("[native code") | ||
return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){O(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){N(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=a.openCursor(),c=1 | ||
u.onsuccess=function(){var n=u.result | ||
if(n){var r=n.value | ||
x(r)&&(r=S(r)) | ||
x(r)&&(r=E(r)) | ||
var o=e(r,n.key,c++) | ||
@@ -109,13 +109,13 @@ void 0!==o?t(o):n.continue()}else t()},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
e=s(e) | ||
var r=new a(function(t,r){n.ready().then(function(){O(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
var r=new a(function(t,r){n.ready().then(function(){N(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=a.get(e) | ||
u.onsuccess=function(){var e=u.result | ||
void 0===e&&(e=null),x(e)&&(e=S(e)),t(e)},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
void 0===e&&(e=null),x(e)&&(e=E(e)),t(e)},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return u(r,t),r},setItem:function(e,t,n){var r=this | ||
e=s(e) | ||
var o=new a(function(n,o){var i | ||
r.ready().then(function(){return i=r._dbInfo,"[object Blob]"===h.call(t)?m(i.db).then(function(e){return e?t:(n=t,new a(function(e,t){var r=new FileReader | ||
r.ready().then(function(){return i=r._dbInfo,"[object Blob]"===v.call(t)?m(i.db).then(function(e){return e?t:(n=t,new a(function(e,t){var r=new FileReader | ||
r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"") | ||
e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})) | ||
var n}):t}).then(function(t){O(r._dbInfo,y,function(i,a){if(i)return o(i) | ||
var n}):t}).then(function(t){N(r._dbInfo,y,function(i,a){if(i)return o(i) | ||
try{var u=a.objectStore(r._dbInfo.storeName) | ||
@@ -128,18 +128,18 @@ null===t&&(t=void 0) | ||
e=s(e) | ||
var r=new a(function(t,r){n.ready().then(function(){O(n._dbInfo,y,function(o,i){if(o)return r(o) | ||
var r=new a(function(t,r){n.ready().then(function(){N(n._dbInfo,y,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=a.delete(e) | ||
i.oncomplete=function(){t()},i.onerror=function(){r(u.error)},i.onabort=function(){var e=u.error?u.error:u.transaction.error | ||
r(e)}}catch(e){r(e)}})}).catch(r)}) | ||
return u(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){O(t._dbInfo,y,function(r,o){if(r)return n(r) | ||
return u(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,y,function(r,o){if(r)return n(r) | ||
try{var i=o.objectStore(t._dbInfo.storeName),a=i.clear() | ||
o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=a.error?a.error:a.transaction.error | ||
n(e)}}catch(e){n(e)}})}).catch(n)}) | ||
return u(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){O(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
return u(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
try{var i=o.objectStore(t._dbInfo.storeName),a=i.count() | ||
a.onsuccess=function(){e(a.result)},a.onerror=function(){n(a.error)}}catch(e){n(e)}})}).catch(n)}) | ||
return u(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){e<0?t(null):n.ready().then(function(){O(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
return u(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){e<0?t(null):n.ready().then(function(){N(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=!1,c=a.openCursor() | ||
c.onsuccess=function(){var n=c.result | ||
n?0===e?t(n.key):u?t(n.key):(u=!0,n.advance(e)):t(null)},c.onerror=function(){r(c.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return u(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){O(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
return u(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
try{var i=o.objectStore(t._dbInfo.storeName),a=i.openCursor(),u=[] | ||
@@ -150,3 +150,3 @@ a.onsuccess=function(){var t=a.result | ||
var n,r=this.config() | ||
if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName),e.name){var i=e.name===r.name&&this._dbInfo.db,c=i?a.resolve(this._dbInfo.db):w(e).then(function(t){var n=v[e.name],r=n.forages | ||
if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName),e.name){var i=e.name===r.name&&this._dbInfo.db,c=i?a.resolve(this._dbInfo.db):I(e).then(function(t){var n=d[e.name],r=n.forages | ||
n.db=t | ||
@@ -157,3 +157,3 @@ for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t | ||
b(e) | ||
var r=v[e.name],i=r.forages | ||
var r=d[e.name],i=r.forages | ||
t.close() | ||
@@ -169,3 +169,3 @@ for(var u=0;u<i.length;u++){var c=i[u] | ||
n._dbInfo.db=e,g(n._dbInfo)}}).catch(function(t){throw(_(e,t)||a.resolve()).catch(function(){}),t})}}:function(t){b(e) | ||
var n=v[e.name],r=n.forages | ||
var n=d[e.name],r=n.forages | ||
t.close() | ||
@@ -180,17 +180,17 @@ for(var i=0;i<r.length;i++){var u=r[i] | ||
g(o._dbInfo)}}).catch(function(t){throw(_(e,t)||a.resolve()).catch(function(){}),t})})}else n=a.reject("Invalid arguments") | ||
return u(n,t),n}},D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",C="~~local_forage_type~",P=/^~~local_forage_type~([^~]+)~/,R="__lfsc__:",k=R.length,T="arbf",B="blob",M="si08",L="ui08",F="uic8",z="si16",q="si32",G="ur16",U="ui32",W="fl32",K="fl64",H=k+T.length,Q=Object.prototype.toString | ||
function X(e){var t,n,r,o,i,a=.75*e.length,u=e.length,c=0 | ||
return u(n,t),n}},A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P="~~local_forage_type~",D=/^~~local_forage_type~([^~]+)~/,k="__lfsc__:",R=k.length,T="arbf",B="blob",M="si08",L="ui08",F="uic8",z="si16",q="si32",G="ur16",U="ui32",W="fl32",K="fl64",J=R+T.length,H=Object.prototype.toString | ||
function Q(e){var t,n,r,o,i,a=.75*e.length,u=e.length,c=0 | ||
"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--) | ||
var s=new ArrayBuffer(a),f=new Uint8Array(s) | ||
for(t=0;t<u;t+=4)n=D.indexOf(e[t]),r=D.indexOf(e[t+1]),o=D.indexOf(e[t+2]),i=D.indexOf(e[t+3]),f[c++]=n<<2|r>>4,f[c++]=(15&r)<<4|o>>2,f[c++]=(3&o)<<6|63&i | ||
return s}function J(e){var t,n=new Uint8Array(e),r="" | ||
for(t=0;t<n.length;t+=3)r+=D[n[t]>>2],r+=D[(3&n[t])<<4|n[t+1]>>4],r+=D[(15&n[t+1])<<2|n[t+2]>>6],r+=D[63&n[t+2]] | ||
return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var V={serialize:function(e,t){var n="" | ||
if(e&&(n=Q.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===Q.call(e.buffer))){var r,o=R | ||
e instanceof ArrayBuffer?(r=e,o+=T):(r=e.buffer,"[object Int8Array]"===n?o+=M:"[object Uint8Array]"===n?o+=L:"[object Uint8ClampedArray]"===n?o+=F:"[object Int16Array]"===n?o+=z:"[object Uint16Array]"===n?o+=G:"[object Int32Array]"===n?o+=q:"[object Uint32Array]"===n?o+=U:"[object Float32Array]"===n?o+=W:"[object Float64Array]"===n?o+=K:t(Error("Failed to get type for BinaryArray"))),t(o+J(r))}else if("[object Blob]"===n){var i=new FileReader | ||
i.onload=function(){var n=C+e.type+"~"+J(this.result) | ||
t(R+B+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,k)!==R)return JSON.parse(e) | ||
var t,n=e.substring(H),type=e.substring(k,H) | ||
if(type===B&&P.test(n)){var r=n.match(P) | ||
t=r[1],n=n.substring(r[0].length)}var o=X(n) | ||
for(t=0;t<u;t+=4)n=A.indexOf(e[t]),r=A.indexOf(e[t+1]),o=A.indexOf(e[t+2]),i=A.indexOf(e[t+3]),f[c++]=n<<2|r>>4,f[c++]=(15&r)<<4|o>>2,f[c++]=(3&o)<<6|63&i | ||
return s}function X(e){var t,n=new Uint8Array(e),r="" | ||
for(t=0;t<n.length;t+=3)r+=A[n[t]>>2],r+=A[(3&n[t])<<4|n[t+1]>>4],r+=A[(15&n[t+1])<<2|n[t+2]>>6],r+=A[63&n[t+2]] | ||
return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var Z={serialize:function(e,t){var n="" | ||
if(e&&(n=H.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===H.call(e.buffer))){var r,o=k | ||
e instanceof ArrayBuffer?(r=e,o+=T):(r=e.buffer,"[object Int8Array]"===n?o+=M:"[object Uint8Array]"===n?o+=L:"[object Uint8ClampedArray]"===n?o+=F:"[object Int16Array]"===n?o+=z:"[object Uint16Array]"===n?o+=G:"[object Int32Array]"===n?o+=q:"[object Uint32Array]"===n?o+=U:"[object Float32Array]"===n?o+=W:"[object Float64Array]"===n?o+=K:t(Error("Failed to get type for BinaryArray"))),t(o+X(r))}else if("[object Blob]"===n){var i=new FileReader | ||
i.onload=function(){var n=P+e.type+"~"+X(this.result) | ||
t(k+B+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,R)!==k)return JSON.parse(e) | ||
var t,n=e.substring(J),type=e.substring(R,J) | ||
if(type===B&&D.test(n)){var r=n.match(D) | ||
t=r[1],n=n.substring(r[0].length)}var o=Q(n) | ||
switch(type){case T:return o | ||
@@ -207,8 +207,8 @@ case B:return i([o],{type:t}) | ||
case K:return new Float64Array(o) | ||
default:throw Error("Unkown type: "+type)}},stringToBuffer:X,bufferToString:J} | ||
function Y(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function Z(e,t,n,r,o,i){e.executeSql(n,r,o,function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[name],function(e,u){u.rows.length?i(e,a):Y(e,t,function(){e.executeSql(n,r,o,i)},i)},i):i(e,a)},i)}var $={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null} | ||
default:throw Error("Unkown type: "+type)}},stringToBuffer:Q,bufferToString:X} | ||
function V(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function Y(e,t,n,r,o,i){e.executeSql(n,r,o,function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[name],function(e,u){u.rows.length?i(e,a):V(e,t,function(){e.executeSql(n,r,o,i)},i)},i):i(e,a)},i)}var $={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null} | ||
if(e)for(var r in e)n[r]="string"!=typeof e[r]?""+e[r]:e[r] | ||
var o=new a(function(e,r){try{n.db=openDatabase(n.name,n.version+"",n.description,n.size)}catch(e){return r(e)}n.db.transaction(function(o){Y(o,n,function(){t._dbInfo=n,e()},function(e,t){r(t)})},r)}) | ||
return n.serializer=V,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT * FROM "+o.storeName,[],function(n,r){for(var i=r.rows,a=i.length,u=0;u<a;u++){var c=i.item(u),s=c.value | ||
var o=new a(function(e,r){try{n.db=openDatabase(n.name,n.version+"",n.description,n.size)}catch(e){return r(e)}n.db.transaction(function(o){V(o,n,function(){t._dbInfo=n,e()},function(e,t){r(t)})},r)}) | ||
return n.serializer=Z,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Y(n,o,"SELECT * FROM "+o.storeName,[],function(n,r){for(var i=r.rows,a=i.length,u=0;u<a;u++){var c=i.item(u),s=c.value | ||
if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,c.key,u+1)))return void t(s)}t()},function(e,t){r(t)})})}).catch(r)}) | ||
@@ -218,3 +218,3 @@ return u(r,t),r},getItem:function(e,t){var n=this | ||
var r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],function(e,n){var r=n.rows.length?n.rows.item(0).value:null | ||
o.db.transaction(function(n){Y(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],function(e,n){var r=n.rows.length?n.rows.item(0).value:null | ||
r&&(r=o.serializer.deserialize(r)),t(r)},function(e,t){r(t)})})}).catch(r)}) | ||
@@ -225,3 +225,3 @@ return u(r,t),r},setItem:function(e,t,n){return function e(t,n,r,o){var i=this | ||
var c=n,s=i._dbInfo | ||
s.serializer.serialize(n,function(n,f){f?u(f):s.db.transaction(function(e){Z(e,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[t,n],function(){a(c)},function(e,t){u(t)})},function(n){if(n.code===n.QUOTA_ERR){if(o>0)return void a(e.call(i,t,c,r,o-1)) | ||
s.serializer.serialize(n,function(n,f){f?u(f):s.db.transaction(function(e){Y(e,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[t,n],function(){a(c)},function(e,t){u(t)})},function(n){if(n.code===n.QUOTA_ERR){if(o>0)return void a(e.call(i,t,c,r,o-1)) | ||
u(n)}})})}).catch(u)}) | ||
@@ -231,13 +231,13 @@ return u(c,r),c}.call(this,e,t,n,1)},removeItem:function(e,t){var n=this | ||
var r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){r(t)})})}).catch(r)}) | ||
o.db.transaction(function(n){Y(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){r(t)})})}).catch(r)}) | ||
return u(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"DELETE FROM "+r.storeName,[],function(){e()},function(e,t){n(t)})})}).catch(n)}) | ||
r.db.transaction(function(t){Y(t,r,"DELETE FROM "+r.storeName,[],function(){e()},function(e,t){n(t)})})}).catch(n)}) | ||
return u(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],function(t,n){var r=n.rows.item(0).c | ||
r.db.transaction(function(t){Y(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],function(t,n){var r=n.rows.item(0).c | ||
e(r)},function(e,t){n(t)})})}).catch(n)}) | ||
return u(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,n){var r=n.rows.length?n.rows.item(0).key:null | ||
o.db.transaction(function(n){Y(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,n){var r=n.rows.length?n.rows.item(0).key:null | ||
t(r)},function(e,t){r(t)})})}).catch(r)}) | ||
return u(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"SELECT key FROM "+r.storeName,[],function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key) | ||
r.db.transaction(function(t){Y(t,r,"SELECT key FROM "+r.storeName,[],function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key) | ||
e(r)},function(e,t){n(t)})})}).catch(n)}) | ||
@@ -254,3 +254,3 @@ return u(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments) | ||
if(e)for(var n in e)t[n]=e[n] | ||
return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=V,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then(function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,u=0;u<i;u++){var c=localStorage.key(u) | ||
return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=Z,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then(function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,u=0;u<i;u++){var c=localStorage.key(u) | ||
if(0===c.indexOf(r)){var s=localStorage.getItem(c) | ||
@@ -285,7 +285,7 @@ if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,c.substring(o),a++)))return s}}}) | ||
r++}var o,i | ||
return!1},oe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},ue={INDEXEDDB:A,WEBSQL:$,LOCALSTORAGE:ne},ce=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],se=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),le={description:"",driver:ce.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1} | ||
function de(e,t){e[t]=function(){var n=arguments | ||
return e.ready().then(function(){return e[t].apply(e,n)})}}function ve(){for(var e=1;e<arguments.length;e++){var t=arguments[e] | ||
if(t)for(var n in t)t.hasOwnProperty(n)&&(arguments[0][n]=oe(t[n])?t[n].slice():t[n])}return arguments[0]}var he=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver | ||
this[n]=o,ie[o]||this.defineDriver(r)}this._defaultConfig=ve({},le),this._config=ve({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return Error("Can't call config() after localforage has been used.") | ||
return!1},oe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},ue={INDEXEDDB:C,WEBSQL:$,LOCALSTORAGE:ne},ce=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],se=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),le={description:"",driver:ce.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1} | ||
function he(e,t){e[t]=function(){var n=arguments | ||
return e.ready().then(function(){return e[t].apply(e,n)})}}function de(){for(var e=1;e<arguments.length;e++){var t=arguments[e] | ||
if(t)for(var n in t)t.hasOwnProperty(n)&&(arguments[0][n]=oe(t[n])?t[n].slice():t[n])}return arguments[0]}var ve=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver | ||
this[n]=o,ie[o]||this.defineDriver(r)}this._defaultConfig=de({},le),this._config=de({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return Error("Can't call config() after localforage has been used.") | ||
for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return Error("Database version must be a number.") | ||
@@ -298,6 +298,6 @@ this._config[t]=e[t]}return!("driver"in e&&e.driver)||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new a(function(t,n){try{var r=e._driver,o=Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver") | ||
e[o]||(e[o]=t(o))}}() | ||
var d=function(n){ie[r]&&console.info("Redefining LocalForage driver: "+r),ie[r]=e,ae[r]=n,t()} | ||
"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}) | ||
var h=function(n){ie[r]&&console.info("Redefining LocalForage driver: "+r),ie[r]=e,ae[r]=n,t()} | ||
"_support"in e?e._support&&"function"==typeof e._support?e._support().then(h,n):h(!!e._support):h(!0)}catch(e){n(e)}}) | ||
return c(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ie[e]?a.resolve(ie[e]):a.reject(Error("Driver not found.")) | ||
return c(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(V) | ||
return c(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(Z) | ||
return c(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then(function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}) | ||
@@ -315,4 +315,4 @@ return c(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this | ||
var e=Error("No available storage method found.") | ||
return r._driverSet=a.reject(e),r._driverSet}),c(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){ve(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n] | ||
this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)de(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new he | ||
return r._driverSet=a.reject(e),r._driverSet}),c(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){de(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n] | ||
this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)he(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new ve | ||
t.exports=pe},{3:3}]},{},[4])(4)}),utils=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}) | ||
@@ -328,3 +328,29 @@ var n=Object.prototype.toString | ||
unwrapExports(utils) | ||
var utils_1=utils.isDate,utils_2=utils.isNumber,utils_3=utils.isArray,utils_4=utils.isPlainObject,utils_5=utils.extend,utils_6=utils.omit,Persist_1=createCommonjsModule(function(e,t){var n=commonjsGlobal&&commonjsGlobal.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},r=commonjsGlobal&&commonjsGlobal.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
var utils_1=utils.isDate,utils_2=utils.isNumber,utils_3=utils.isArray,utils_4=utils.isPlainObject,utils_5=utils.extend,utils_6=utils.omit,LZString_1=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}) | ||
var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),o=0,i={},a=r.concat() | ||
for(a[63]="-",a[64]="$";o<65;)o>62&&(i[a[o].charCodeAt(0)]=o),i[r[o].charCodeAt(0)]=o++ | ||
var u=function(e){return{v:e,d:{}}},c=function(e,t,r){for(var o=["","",""],i=4,a=4,u=3,c="",s=[],f=0,l=2,h=0,d="",v=r(0),p=t,y=1;h!==l;)f+=(v>>--p&1)<<h++,0==p&&(p=t,v=r(y++)) | ||
if(2===f)return"" | ||
for(l=8*f+8,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
for(d=n(f),o[3]=d,s.push(d);y<=e;){for(l=u,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
if(f<2){for(l=8+8*f,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
o[a]=n(f),f=a++,0==--i&&(i=1<<u++)}else if(2==f)return s.join("") | ||
if(f>o.length)return null | ||
c=f<o.length?o[f]:d+d.charAt(0),s.push(c),o[a++]=d+c.charAt(0),d=c,0==--i&&(i=1<<u++)}return""},s=function(e){return function(e,t,n){if(null==e)return[] | ||
var r,o=0,i=0,a=0,c=new Map,s=!0,f=0,l=u(3),h=1,d=4,v=2,p=[],y=0,m=0 | ||
if(e.length){for(a=(f=e.charCodeAt(0))<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(c.set(f,l),i=1;i<e.length;i++)if(f=e.charCodeAt(i),r=l.d[f])l=r | ||
else{if(s)s=!1 | ||
else for(a=l.v,o=0;o<v;o++)y=a>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
if(!c.has(f)){for(0==--h&&(h=1<<v++),a=f<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++m==t&&(m=0,p.push(n(y)),y=0) | ||
c.set(f,u(d++)),s=!0}l.d[f]=u(d++),0==--h&&(h=1<<v++),l=c.get(f)}if(s)s=!1 | ||
else for(a=l.v,o=0;o<v;o++)y=a>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
if(!c.has(f)){for(0==--h&&(h=1<<v++),a=f<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0)}0==--h&&(h=1<<v++)}for(o=0;o<v;o++)y=2>>o&1|y<<1,++m===t&&(m=0,p.push(n(y)),y=0) | ||
return p.push(n(y<<=t-m)),p}(e,16,function(e){return n(e)})} | ||
t.default={compress:function(e){return s(e).join("")},compressToArray:s,decompress:function(e){return null===e?"":""===e?null:c(e.length,16,function(t){return e.charCodeAt(t)})},decompressFromArray:function(e){return null===e?"":0===e.length?null:c(e.length,16,function(t){return e[t].charCodeAt(0)})}}}) | ||
unwrapExports(LZString_1) | ||
var Persist_1=createCommonjsModule(function(e,t){var n=commonjsGlobal&&commonjsGlobal.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},r=commonjsGlobal&&commonjsGlobal.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
return o[1]},trys:[],ops:[]} | ||
@@ -349,17 +375,35 @@ return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i | ||
Object.defineProperty(t,"__esModule",{value:!0}) | ||
var o={driver:[localforage.INDEXEDDB,localforage.LOCALSTORAGE],valueMaxLength:5e5,autoClearExpires:!1},i=function(){function e(e){void 0===e&&(e={}) | ||
var t=this | ||
this.cacheConfig=utils.extend(e,o),this.cacheInstance=localforage.createInstance(this.cacheConfig),this.cacheConfig.autoClearExpires&&(window.onbeforeunload=function(e){t.clearExpires()})}return e.prototype.clearExpires=function(){var e=this | ||
return this.cacheInstance.iterate(function(t,n){Promise.all([e.isExpired(t),e.isOverLength(t)]).then(function(t){(t[0]||t[1])&&e.cacheInstance.removeItem(n)})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.isOverLength=function(e){return n(this,void 0,void 0,function(){var t,n | ||
var o={driver:[localforage.INDEXEDDB,localforage.LOCALSTORAGE],valueMaxLength:5e5,isCompress:!1},i=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=utils.extend(e,o),this.cacheInstance=localforage.createInstance(this.cacheConfig)}return e.prototype.autoClear=function(){var e=this | ||
return this.cacheInstance.iterate(function(t,n){Promise.all([e.isExpired(t),e.isOverLength(t)]).then(function(t){(t[0]||t[1])&&e.remove(n)})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.isOverLength=function(e){return n(this,void 0,void 0,function(){var t,n | ||
return r(this,function(r){switch(r.label){case 0:return t=this.cacheConfig.valueMaxLength,[4,this.cacheInstance.getSerializer()] | ||
case 1:return n=r.sent(),[2,new Promise(function(r,o){n.serialize(e,function(e,n){n&&o(n),r(e.lenth>(t||0))})})]}})})},e.prototype.dropInstance=function(e){return void 0===e&&(e={}),this.cacheInstance.dropInstance(e)},e.prototype.getItem=function(e){return n(this,void 0,void 0,function(){var t,n,o | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.cacheInstance.getItem(e)] | ||
case 1:return n=r.sent(),[2,new Promise(function(r,o){n.serialize(e,function(e,n){n&&o(n),r(e.lenth>(t||0))})})]}})})},e.prototype.dropInstance=function(e){return void 0===e&&(e={}),this.cacheInstance.dropInstance(e)},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),[4,this.getItem(e)] | ||
case 1:return t=r.sent(),[4,this.isExpired(t)] | ||
case 2:return n=r.sent(),t&&t.value?n?(this.cacheInstance.removeItem(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[3,4]:[2,Promise.resolve(null)] | ||
case 3:return o=r.sent(),[2,Promise.reject(o)] | ||
case 4:return[2]}})})},e.prototype.setItem=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){return r(this,function(n){return utils.isDate(o)?o=o.getTime():utils.isNumber(o)&&o>0&&(o=(new Date).getTime()+1e3*o),[2,this.cacheInstance.setItem(e,{value:t,expire:o})]})})},e.prototype.appendItem=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){var n,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.cacheInstance.getItem(e)] | ||
case 2:return n=r.sent(),t&&t.value?[3,3]:[2,Promise.resolve(null)] | ||
case 3:return n?(this.remove(e),[2,Promise.resolve(null)]):[3,4] | ||
case 4:return t.value?(o=t.value,this.cacheConfig.isCompress&&(o=JSON.parse(LZString_1.default.decompress(t.value))),[4,this.set(e,t.value,t.expire)]):[3,6] | ||
case 5:return r.sent(),[2,Promise.resolve(o)] | ||
case 6:return[3,8] | ||
case 7:return i=r.sent(),[2,Promise.reject(i)] | ||
case 8:return[2]}})})},e.prototype.gets=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:t=[],n=0,r.label=1 | ||
case 1:return n<e.length?(i=(o=t).push,[4,this.get(e[n])]):[3,4] | ||
case 2:i.call(o,r.sent()),r.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(t)]}})})},e.prototype.set=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){var n,i,a,u | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.cacheInstance.getSerializer()] | ||
case 1:return r.sent(),n=(new Date).getTime(),utils.isDate(o)?o=o.getTime():utils.isNumber(o)&&o>0&&(o=n+1e3*o),[4,this.setItem(e,{value:this.cacheConfig.isCompress?LZString_1.default.compress(JSON.stringify(t)):t,expire:o,now:n})] | ||
case 2:return i=r.sent(),a=this.cacheConfig.isCompress?JSON.parse(LZString_1.default.decompress(i.value)):i.value,[2,Promise.resolve(a)] | ||
case 3:return u=r.sent(),[2,Promise.reject(u)] | ||
case 4:return[2]}})})},e.prototype.append=function(e,t,o){return void 0===o&&(o=-1),n(this,void 0,void 0,function(){var n,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getItem(e)] | ||
case 1:return n=r.sent(),[3,3] | ||
case 2:return i=r.sent(),[2,Promise.reject(i)] | ||
case 3:return n?(utils.isArray(t)&&utils.isArray(n.value)?t=n.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(n.value)&&(t=utils.extend(n.value,t)),[2,this.setItem(e,t,o=o||n.expire)]):[2,this.setItem(e,t,o)]}})})},e.prototype.removeItem=function(e){return this.cacheInstance.removeItem(e)},e.prototype.clear=function(){return this.cacheInstance.clear()},e.prototype.length=function(){return this.cacheInstance.length()},e.prototype.iterate=function(e,t){return void 0===t&&(t=null),this.cacheInstance.iterate(e,t)},e}() | ||
case 3:return n?(utils.isArray(t)&&utils.isArray(n.value)?t=n.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(n.value)&&(t=utils.extend(n.value,t)),[2,this.set(e,t,o=o||n.expire)]):[2,this.set(e,t,o)]}})})},e.prototype.has=function(e){return n(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,this.get(e)] | ||
case 1:return t.sent()?[2,Promise.resolve(!0)]:[2,Promise.resolve(!1)]}})})},e.prototype.remove=function(e){return this.cacheInstance.removeItem(e)},e.prototype.keys=function(){return this.cacheInstance.keys()},e.prototype.clear=function(){return this.cacheInstance.clear()},e.prototype.length=function(){return this.cacheInstance.length()},e.prototype.each=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=[],[4,this.cacheInstance.iterate(function(e,n,r){t.push({key:n,value:e})})] | ||
case 1:for(r.sent(),n=t.sort(function(e,t){return e.value.now-e.value.now}),o=0;o<n.length;o++)e&&e(n[o].value.value,n[o].key,o) | ||
return[2,Promise.resolve(!0)] | ||
case 2:return i=r.sent(),[2,Promise.reject(i)] | ||
case 3:return[2]}})})},e.prototype.getItem=function(e){return this.cacheInstance.getItem(e)},e.prototype.setItem=function(e,t){return n(this,void 0,void 0,function(){return r(this,function(n){return[2,this.cacheInstance.setItem(e,t)]})})},e}() | ||
t.default=i}) | ||
@@ -387,14 +431,21 @@ unwrapExports(Persist_1) | ||
Object.defineProperty(t,"__esModule",{value:!0}) | ||
var o=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=utils.extend(e,{name:"memcache"}),this.cacheInstance={}}return e.prototype.clearExpires=function(){return n(this,void 0,void 0,function(){var e=this | ||
var o=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=utils.extend(e,{name:"memcache"}),this.cacheInstance={}}return e.prototype.autoClear=function(){return n(this,void 0,void 0,function(){var e=this | ||
return r(this,function(t){return Object.keys(this.cacheInstance).forEach(function(t,o){return n(e,void 0,void 0,function(){var e,n | ||
return r(this,function(r){switch(r.label){case 0:return e=this.cacheInstance[t],n=t.replace(this.cacheConfig.name+"/",""),[4,this.isExpired(e)] | ||
case 1:return r.sent()&&this.removeItem(n),[2]}})})}),[2,Promise.resolve(!0)]})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.getKey=function(e){return this.cacheConfig.name+"/"+e},e.prototype.getItem=function(e){return n(this,void 0,void 0,function(){var t,n | ||
case 1:return r.sent()&&this.remove(n),[2]}})})}),[2,Promise.resolve(!0)]})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.getKey=function(e){return this.cacheConfig.name+"/"+e},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t,n | ||
return r(this,function(r){switch(r.label){case 0:return e=this.getKey(e),[4,this.isExpired(t=this.cacheInstance[e])] | ||
case 1:return n=r.sent(),t&&t.value?n?(this.removeItem(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[2]:[2,Promise.resolve(null)]}})})},e.prototype.setItem=function(e,t,n){return void 0===n&&(n=-1),e=this.getKey(e),utils.isDate(n)?n=n.getTime():utils.isNumber(n)&&n>0&&(n=(new Date).getTime()+1e3*n),this.cacheInstance[e]={value:t,expire:n},Promise.resolve(t)},e.prototype.appendItem=function(e,t,n){void 0===n&&(n=-1) | ||
case 1:return n=r.sent(),t&&t.value?n?(this.remove(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[2]:[2,Promise.resolve(null)]}})})},e.prototype.gets=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:t=[],n=0,r.label=1 | ||
case 1:return n<e.length?(i=(o=t).push,[4,this.get(e[n])]):[3,4] | ||
case 2:i.call(o,r.sent()),r.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(t)]}})})},e.prototype.set=function(e,t,n){return void 0===n&&(n=-1),e=this.getKey(e),utils.isDate(n)?n=n.getTime():utils.isNumber(n)&&n>0&&(n=(new Date).getTime()+1e3*n),this.cacheInstance[e]={value:t,expire:n},Promise.resolve(t)},e.prototype.append=function(e,t,n){void 0===n&&(n=-1) | ||
var r=this.cacheInstance[this.getKey(e)] | ||
return r?(utils.isArray(t)&&utils.isArray(r.value)?t=r.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(r.value)&&(t=utils.extend(r.value,t)),this.setItem(e,t,n=n||r.expire)):this.setItem(e,t,n)},e.prototype.removeItem=function(e){return e=this.getKey(e),this.cacheInstance[e]&&(this.cacheInstance[e]=null,this.cacheInstance=utils.omit(this.cacheInstance,e)),Promise.resolve()},e.prototype.clear=function(){return this.cacheInstance={},Promise.resolve()},e.prototype.length=function(){var e=Object.keys(this.cacheInstance) | ||
return e.length?Promise.resolve(e.length):Promise.resolve(0)},e.prototype.iterate=function(e,t){return void 0===t&&(t=null),n(this,void 0,void 0,function(){var o,i,a=this | ||
return r(this,function(u){return i=(o=Object.keys(this.cacheInstance)).length>0?this.cacheInstance[o[o.length-1]].value:null,o.forEach(function(t,o){return n(a,void 0,void 0,function(){var n | ||
return r(this,function(r){switch(r.label){case 0:return t=t.replace(this.cacheConfig.name+"/",""),[4,this.getItem(t)] | ||
case 1:return n=r.sent(),e(n,t,o),[2]}})})}),t&&t(null,i),[2,Promise.resolve(i)]})})},e}() | ||
return r?(utils.isArray(t)&&utils.isArray(r.value)?t=r.value.concat(t):utils.isPlainObject(t)&&utils.isPlainObject(r.value)&&(t=utils.extend(r.value,t)),this.set(e,t,n=n||r.expire)):this.set(e,t,n)},e.prototype.has=function(e){return this.get(e)?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.remove=function(e){return e=this.getKey(e),this.cacheInstance[e]&&(this.cacheInstance[e]=null,this.cacheInstance=utils.omit(this.cacheInstance,e)),Promise.resolve()},e.prototype.keys=function(){return Promise.resolve(Object.keys(this.cacheInstance))},e.prototype.clear=function(){return this.cacheInstance={},Promise.resolve()},e.prototype.length=function(){var e=Object.keys(this.cacheInstance) | ||
return e.length?Promise.resolve(e.length):Promise.resolve(0)},e.prototype.each=function(e){return n(this,void 0,void 0,function(){var t,n,o,i | ||
return r(this,function(r){switch(r.label){case 0:t=Object.keys(this.cacheInstance),n=0,r.label=1 | ||
case 1:return n<t.length?(o=t[n].replace(this.cacheConfig.name+"/",""),[4,this.get(o)]):[3,4] | ||
case 2:i=r.sent(),e&&e(i,o,n),r.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(!0)]}})})},e}() | ||
t.default=o}) | ||
@@ -401,0 +452,0 @@ unwrapExports(Cache_1) |
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.Mycache={})}(this,function(e){"use strict" | ||
var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{} | ||
function n(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e,t){return e(t={exports:{}},t.exports),t.exports}var i=o(function(e,r){e.exports=function e(t,r,o){function i(c,u){if(!r[c]){if(!t[c]){var s=n | ||
if(!u&&s)return s(c,!0) | ||
if(a)return a(c,!0) | ||
var f=Error("Cannot find module '"+c+"'") | ||
throw f.code="MODULE_NOT_FOUND",f}var l=r[c]={exports:{}} | ||
t[c][0].call(l.exports,function(e){var n=t[c][1][e] | ||
return i(n||e)},l,l.exports,e,t,r,o)}return r[c].exports}for(var a=n,c=0;c<o.length;c++)i(o[c]) | ||
function n(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e,t){return e(t={exports:{}},t.exports),t.exports}var i=o(function(e,r){e.exports=function e(t,r,o){function i(u,c){if(!r[u]){if(!t[u]){var s=n | ||
if(!c&&s)return s(u,!0) | ||
if(a)return a(u,!0) | ||
var f=Error("Cannot find module '"+u+"'") | ||
throw f.code="MODULE_NOT_FOUND",f}var l=r[u]={exports:{}} | ||
t[u][0].call(l.exports,function(e){var n=t[u][1][e] | ||
return i(n||e)},l,l.exports,e,t,r,o)}return r[u].exports}for(var a=n,u=0;u<o.length;u++)i(o[u]) | ||
return i}({1:[function(e,n,r){!function(e){var t,r,o=e.MutationObserver||e.WebKitMutationObserver | ||
if(o){var i=0,a=new o(f),c=e.document.createTextNode("") | ||
a.observe(c,{characterData:!0}),t=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)t="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script") | ||
if(o){var i=0,a=new o(f),u=e.document.createTextNode("") | ||
a.observe(u,{characterData:!0}),t=function(){u.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)t="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script") | ||
t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)} | ||
else{var u=new e.MessageChannel | ||
u.port1.onmessage=f,t=function(){u.port2.postMessage(0)}}var s=[] | ||
else{var c=new e.MessageChannel | ||
c.port1.onmessage=f,t=function(){c.port2.postMessage(0)}}var s=[] | ||
function f(){var e,t | ||
@@ -20,18 +20,18 @@ r=!0 | ||
n=s.length}r=!1}n.exports=function(e){1!==s.push(e)||r||t()}}(void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var r=e(1) | ||
function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],u=["PENDING"] | ||
function o(){}var i={},a=["REJECTED"],u=["FULFILLED"],c=["PENDING"] | ||
function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function") | ||
this.state=u,this.queue=[],this.outcome=void 0,e!==o&&v(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r(function(){var r | ||
try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)})}function d(e){var t=e&&e.then | ||
if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function v(e,t){var n=!1 | ||
function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=h(function(){t(o,r)}) | ||
"error"===a.status&&r(a.value)}function h(e,t){var n={} | ||
try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this | ||
this.state=c,this.queue=[],this.outcome=void 0,e!==o&&d(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r(function(){var r | ||
try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)})}function h(e){var t=e&&e.then | ||
if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function d(e,t){var n=!1 | ||
function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=v(function(){t(o,r)}) | ||
"error"===a.status&&r(a.value)}function v(e,t){var n={} | ||
try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===u||"function"!=typeof t&&this.state===a)return this | ||
var n=new this.constructor(o) | ||
if(this.state!==u){var r=this.state===c?e:t | ||
if(this.state!==c){var r=this.state===u?e:t | ||
l(n,r,this.outcome)}else this.queue.push(new f(n,e,t)) | ||
return n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=h(d,t) | ||
return n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(h,t) | ||
if("error"===n.status)return i.reject(e,n.value) | ||
var r=n.value | ||
if(r)v(e,r) | ||
else{e.state=c,e.outcome=t | ||
if(r)d(e,r) | ||
else{e.state=u,e.outcome=t | ||
for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t | ||
@@ -44,10 +44,10 @@ for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t) | ||
if(!n)return this.resolve([]) | ||
for(var a=Array(n),c=0,u=-1,s=new this(o);++u<n;)f(e[u],u) | ||
for(var a=Array(n),u=0,c=-1,s=new this(o);++c<n;)f(e[c],c) | ||
return s | ||
function f(e,o){t.resolve(e).then(function(e){a[o]=e,++c!==n||r||(r=!0,i.resolve(s,a))},function(e){r||(r=!0,i.reject(s,e))})}},s.race=function(e){var t=this | ||
function f(e,o){t.resolve(e).then(function(e){a[o]=e,++u!==n||r||(r=!0,i.resolve(s,a))},function(e){r||(r=!0,i.reject(s,e))})}},s.race=function(e){var t=this | ||
if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array")) | ||
var n=e.length,r=!1 | ||
if(!n)return this.resolve([]) | ||
for(var a=-1,c=new this(o);++a<n;)t.resolve(e[a]).then(function(e){r||(r=!0,i.resolve(c,e))},function(e){r||(r=!0,i.reject(c,e))}) | ||
return c}},{1:1}],3:[function(e,n,r){var o | ||
for(var a=-1,u=new this(o);++a<n;)t.resolve(e[a]).then(function(e){r||(r=!0,i.resolve(u,e))},function(e){r||(r=!0,i.reject(u,e))}) | ||
return u}},{1:1}],3:[function(e,n,r){var o | ||
"function"!=typeof(o=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}).Promise&&(o.Promise=e(2))},{2:2}],4:[function(e,t,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){try{if("undefined"!=typeof indexedDB)return indexedDB | ||
@@ -63,9 +63,9 @@ if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB | ||
var a=Promise | ||
function c(e,t){t&&e.then(function(e){t(null,e)},function(e){t(e)})}function u(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e+=""),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,v={},h=Object.prototype.toString,p="readonly",y="readwrite" | ||
function b(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a(function(t){var n=e.transaction(l,y),r=i([""]) | ||
function u(e,t){t&&e.then(function(e){t(null,e)},function(e){t(e)})}function c(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e+=""),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",h=void 0,d={},v=Object.prototype.toString,p="readonly",y="readwrite" | ||
function b(e){return"boolean"==typeof h?a.resolve(h):function(e){return new a(function(t){var n=e.transaction(l,y),r=i([""]) | ||
n.objectStore(l).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//) | ||
t(n||!e||parseInt(e[1],10)>=43)}}).catch(function(){return!1})}(e).then(function(e){return d=e})}function m(e){var t=v[e.name],n={} | ||
n.promise=new a(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady=t.dbReady?t.dbReady.then(function(){return n.promise}):n.promise}function g(e){var t=v[e.name],n=t.deferredOperations.pop() | ||
if(n)return n.resolve(),n.promise}function _(e,t){var n=v[e.name],r=n.deferredOperations.pop() | ||
if(r)return r.reject(t),r.promise}function I(e,t){return new a(function(n,r){if(v[e.name]=v[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db) | ||
t(n||!e||parseInt(e[1],10)>=43)}}).catch(function(){return!1})}(e).then(function(e){return h=e})}function m(e){var t=d[e.name],n={} | ||
n.promise=new a(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady=t.dbReady?t.dbReady.then(function(){return n.promise}):n.promise}function g(e){var t=d[e.name],n=t.deferredOperations.pop() | ||
if(n)return n.resolve(),n.promise}function _(e,t){var n=d[e.name],r=n.deferredOperations.pop() | ||
if(r)return r.reject(t),r.promise}function I(e,t){return new a(function(n,r){if(d[e.name]=d[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db) | ||
m(e),e.db.close()}var i=[e.name] | ||
@@ -76,23 +76,23 @@ t&&i.push(e.version) | ||
try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n | ||
console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){n(a.result),g(e)}})}function w(e){return I(e,!1)}function S(e){return I(e,!0)}function E(e,t){if(!e.db)return!0 | ||
console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){n(a.result),g(e)}})}function w(e){return I(e,!1)}function S(e){return I(e,!0)}function j(e,t){if(!e.db)return!0 | ||
var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version | ||
if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1 | ||
i>e.version&&(e.version=i)}return!0}return!1}function j(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o) | ||
i>e.version&&(e.version=i)}return!0}return!1}function E(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o) | ||
return n}(atob(e.data)) | ||
return i([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then(function(){var e=v[t._dbInfo.name] | ||
return i([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then(function(){var e=d[t._dbInfo.name] | ||
if(e&&e.dbReady)return e.dbReady}) | ||
return u(n,e,e),n}function N(e,t,n,r){void 0===r&&(r=1) | ||
return c(n,e,e),n}function N(e,t,n,r){void 0===r&&(r=1) | ||
try{var o=e.db.transaction(e.storeName,t) | ||
n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then(function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),S(e)}).then(function(){return function(e){m(e) | ||
for(var t=v[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r] | ||
o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,w(e).then(function(t){return e.db=t,E(e)?S(e):t}).then(function(r){e.db=t.db=r | ||
for(var t=d[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r] | ||
o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,w(e).then(function(t){return e.db=t,j(e)?S(e):t}).then(function(r){e.db=t.db=r | ||
for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r}).catch(function(t){throw _(e,t),t})}(e).then(function(){N(e,t,n,r-1)})}).catch(n) | ||
n(o)}}var A={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null} | ||
if(e)for(var r in e)n[r]=e[r] | ||
var o=v[n.name] | ||
o||(v[n.name]=o={forages:[],db:null,dbReady:null,deferredOperations:[]}),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O) | ||
var o=d[n.name] | ||
o||(d[n.name]=o={forages:[],db:null,dbReady:null,deferredOperations:[]}),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O) | ||
var i=[] | ||
function c(){return a.resolve()}for(var u=0;u<o.forages.length;u++){var s=o.forages[u] | ||
s!==t&&i.push(s._initReady().catch(c))}var f=o.forages.slice(0) | ||
return a.all(i).then(function(){return n.db=o.db,w(n)}).then(function(e){return n.db=e,E(n,t._defaultConfig.version)?S(n):e}).then(function(e){n.db=o.db=e,t._dbInfo=n | ||
function u(){return a.resolve()}for(var c=0;c<o.forages.length;c++){var s=o.forages[c] | ||
s!==t&&i.push(s._initReady().catch(u))}var f=o.forages.slice(0) | ||
return a.all(i).then(function(){return n.db=o.db,w(n)}).then(function(e){return n.db=e,j(n,t._defaultConfig.version)?S(n):e}).then(function(e){n.db=o.db=e,t._dbInfo=n | ||
for(var r=0;r<f.length;r++){var i=f[r] | ||
@@ -102,59 +102,59 @@ i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}})},_support:function(){try{if(!o)return!1 | ||
return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){N(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),c=a.openCursor(),u=1 | ||
c.onsuccess=function(){var n=c.result | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=a.openCursor(),c=1 | ||
u.onsuccess=function(){var n=u.result | ||
if(n){var r=n.value | ||
x(r)&&(r=j(r)) | ||
var o=e(r,n.key,u++) | ||
void 0!==o?t(o):n.continue()}else t()},c.onerror=function(){r(c.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return c(r,t),r},getItem:function(e,t){var n=this | ||
x(r)&&(r=E(r)) | ||
var o=e(r,n.key,c++) | ||
void 0!==o?t(o):n.continue()}else t()},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return u(r,t),r},getItem:function(e,t){var n=this | ||
e=s(e) | ||
var r=new a(function(t,r){n.ready().then(function(){N(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),c=a.get(e) | ||
c.onsuccess=function(){var e=c.result | ||
void 0===e&&(e=null),x(e)&&(e=j(e)),t(e)},c.onerror=function(){r(c.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return c(r,t),r},setItem:function(e,t,n){var r=this | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=a.get(e) | ||
u.onsuccess=function(){var e=u.result | ||
void 0===e&&(e=null),x(e)&&(e=E(e)),t(e)},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return u(r,t),r},setItem:function(e,t,n){var r=this | ||
e=s(e) | ||
var o=new a(function(n,o){var i | ||
r.ready().then(function(){return i=r._dbInfo,"[object Blob]"===h.call(t)?b(i.db).then(function(e){return e?t:(n=t,new a(function(e,t){var r=new FileReader | ||
r.ready().then(function(){return i=r._dbInfo,"[object Blob]"===v.call(t)?b(i.db).then(function(e){return e?t:(n=t,new a(function(e,t){var r=new FileReader | ||
r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"") | ||
e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})) | ||
var n}):t}).then(function(t){N(r._dbInfo,y,function(i,a){if(i)return o(i) | ||
try{var c=a.objectStore(r._dbInfo.storeName) | ||
try{var u=a.objectStore(r._dbInfo.storeName) | ||
null===t&&(t=void 0) | ||
var u=c.put(t,e) | ||
a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=u.error?u.error:u.transaction.error | ||
var c=u.put(t,e) | ||
a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=c.error?c.error:c.transaction.error | ||
o(e)}}catch(e){o(e)}})}).catch(o)}) | ||
return c(o,n),o},removeItem:function(e,t){var n=this | ||
return u(o,n),o},removeItem:function(e,t){var n=this | ||
e=s(e) | ||
var r=new a(function(t,r){n.ready().then(function(){N(n._dbInfo,y,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),c=a.delete(e) | ||
i.oncomplete=function(){t()},i.onerror=function(){r(c.error)},i.onabort=function(){var e=c.error?c.error:c.transaction.error | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=a.delete(e) | ||
i.oncomplete=function(){t()},i.onerror=function(){r(u.error)},i.onabort=function(){var e=u.error?u.error:u.transaction.error | ||
r(e)}}catch(e){r(e)}})}).catch(r)}) | ||
return c(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,y,function(r,o){if(r)return n(r) | ||
return u(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,y,function(r,o){if(r)return n(r) | ||
try{var i=o.objectStore(t._dbInfo.storeName),a=i.clear() | ||
o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=a.error?a.error:a.transaction.error | ||
n(e)}}catch(e){n(e)}})}).catch(n)}) | ||
return c(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
return u(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
try{var i=o.objectStore(t._dbInfo.storeName),a=i.count() | ||
a.onsuccess=function(){e(a.result)},a.onerror=function(){n(a.error)}}catch(e){n(e)}})}).catch(n)}) | ||
return c(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){e<0?t(null):n.ready().then(function(){N(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),c=!1,u=a.openCursor() | ||
u.onsuccess=function(){var n=u.result | ||
n?0===e?t(n.key):c?t(n.key):(c=!0,n.advance(e)):t(null)},u.onerror=function(){r(u.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return c(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
try{var i=o.objectStore(t._dbInfo.storeName),a=i.openCursor(),c=[] | ||
return u(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){e<0?t(null):n.ready().then(function(){N(n._dbInfo,p,function(o,i){if(o)return r(o) | ||
try{var a=i.objectStore(n._dbInfo.storeName),u=!1,c=a.openCursor() | ||
c.onsuccess=function(){var n=c.result | ||
n?0===e?t(n.key):u?t(n.key):(u=!0,n.advance(e)):t(null)},c.onerror=function(){r(c.error)}}catch(e){r(e)}})}).catch(r)}) | ||
return u(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){N(t._dbInfo,p,function(r,o){if(r)return n(r) | ||
try{var i=o.objectStore(t._dbInfo.storeName),a=i.openCursor(),u=[] | ||
a.onsuccess=function(){var t=a.result | ||
t?(c.push(t.key),t.continue()):e(c)},a.onerror=function(){n(a.error)}}catch(e){n(e)}})}).catch(n)}) | ||
return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments) | ||
t?(u.push(t.key),t.continue()):e(u)},a.onerror=function(){n(a.error)}}catch(e){n(e)}})}).catch(n)}) | ||
return u(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments) | ||
var n,r=this.config() | ||
if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName),e.name){var i=e.name===r.name&&this._dbInfo.db,u=i?a.resolve(this._dbInfo.db):w(e).then(function(t){var n=v[e.name],r=n.forages | ||
if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName),e.name){var i=e.name===r.name&&this._dbInfo.db,c=i?a.resolve(this._dbInfo.db):w(e).then(function(t){var n=d[e.name],r=n.forages | ||
n.db=t | ||
for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t | ||
return t}) | ||
n=u.then(e.storeName?function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1 | ||
n=c.then(e.storeName?function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1 | ||
m(e) | ||
var r=v[e.name],i=r.forages | ||
var r=d[e.name],i=r.forages | ||
t.close() | ||
for(var c=0;c<i.length;c++){var u=i[c] | ||
u._dbInfo.db=null,u._dbInfo.version=n}var s=new a(function(t,r){var i=o.open(e.name,n) | ||
for(var u=0;u<i.length;u++){var c=i[u] | ||
c._dbInfo.db=null,c._dbInfo.version=n}var s=new a(function(t,r){var i=o.open(e.name,n) | ||
i.onerror=function(e){var t=i.result | ||
@@ -167,31 +167,31 @@ t.close(),r(e)},i.onupgradeneeded=function(){var t=i.result | ||
n._dbInfo.db=e,g(n._dbInfo)}}).catch(function(t){throw(_(e,t)||a.resolve()).catch(function(){}),t})}}:function(t){m(e) | ||
var n=v[e.name],r=n.forages | ||
var n=d[e.name],r=n.forages | ||
t.close() | ||
for(var i=0;i<r.length;i++){var c=r[i] | ||
c._dbInfo.db=null}var u=new a(function(t,n){var r=o.deleteDatabase(e.name) | ||
for(var i=0;i<r.length;i++){var u=r[i] | ||
u._dbInfo.db=null}var c=new a(function(t,n){var r=o.deleteDatabase(e.name) | ||
r.onerror=r.onblocked=function(e){var t=r.result | ||
t&&t.close(),n(e)},r.onsuccess=function(){var e=r.result | ||
e&&e.close(),t(e)}}) | ||
return u.then(function(e){n.db=e | ||
return c.then(function(e){n.db=e | ||
for(var t=0;t<r.length;t++){var o=r[t] | ||
g(o._dbInfo)}}).catch(function(t){throw(_(e,t)||a.resolve()).catch(function(){}),t})})}else n=a.reject("Invalid arguments") | ||
return c(n,t),n}},D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P="~~local_forage_type~",R=/^~~local_forage_type~([^~]+)~/,k="__lfsc__:",C=k.length,T="arbf",B="blob",L="si08",M="ui08",F="uic8",z="si16",U="si32",q="ur16",W="ui32",K="fl32",G="fl64",H=C+T.length,Q=Object.prototype.toString | ||
function X(e){var t,n,r,o,i,a=.75*e.length,c=e.length,u=0 | ||
return u(n,t),n}},P="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",C="~~local_forage_type~",D=/^~~local_forage_type~([^~]+)~/,k="__lfsc__:",R=k.length,T="arbf",B="blob",M="si08",L="ui08",F="uic8",z="si16",U="si32",q="ur16",W="ui32",K="fl32",G="fl64",J=R+T.length,H=Object.prototype.toString | ||
function Q(e){var t,n,r,o,i,a=.75*e.length,u=e.length,c=0 | ||
"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--) | ||
var s=new ArrayBuffer(a),f=new Uint8Array(s) | ||
for(t=0;t<c;t+=4)n=D.indexOf(e[t]),r=D.indexOf(e[t+1]),o=D.indexOf(e[t+2]),i=D.indexOf(e[t+3]),f[u++]=n<<2|r>>4,f[u++]=(15&r)<<4|o>>2,f[u++]=(3&o)<<6|63&i | ||
return s}function J(e){var t,n=new Uint8Array(e),r="" | ||
for(t=0;t<n.length;t+=3)r+=D[n[t]>>2],r+=D[(3&n[t])<<4|n[t+1]>>4],r+=D[(15&n[t+1])<<2|n[t+2]>>6],r+=D[63&n[t+2]] | ||
for(t=0;t<u;t+=4)n=P.indexOf(e[t]),r=P.indexOf(e[t+1]),o=P.indexOf(e[t+2]),i=P.indexOf(e[t+3]),f[c++]=n<<2|r>>4,f[c++]=(15&r)<<4|o>>2,f[c++]=(3&o)<<6|63&i | ||
return s}function X(e){var t,n=new Uint8Array(e),r="" | ||
for(t=0;t<n.length;t+=3)r+=P[n[t]>>2],r+=P[(3&n[t])<<4|n[t+1]>>4],r+=P[(15&n[t+1])<<2|n[t+2]>>6],r+=P[63&n[t+2]] | ||
return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var V={serialize:function(e,t){var n="" | ||
if(e&&(n=Q.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===Q.call(e.buffer))){var r,o=k | ||
e instanceof ArrayBuffer?(r=e,o+=T):(r=e.buffer,"[object Int8Array]"===n?o+=L:"[object Uint8Array]"===n?o+=M:"[object Uint8ClampedArray]"===n?o+=F:"[object Int16Array]"===n?o+=z:"[object Uint16Array]"===n?o+=q:"[object Int32Array]"===n?o+=U:"[object Uint32Array]"===n?o+=W:"[object Float32Array]"===n?o+=K:"[object Float64Array]"===n?o+=G:t(Error("Failed to get type for BinaryArray"))),t(o+J(r))}else if("[object Blob]"===n){var i=new FileReader | ||
i.onload=function(){var n=P+e.type+"~"+J(this.result) | ||
t(k+B+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,C)!==k)return JSON.parse(e) | ||
var t,n=e.substring(H),type=e.substring(C,H) | ||
if(type===B&&R.test(n)){var r=n.match(R) | ||
t=r[1],n=n.substring(r[0].length)}var o=X(n) | ||
if(e&&(n=H.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===H.call(e.buffer))){var r,o=k | ||
e instanceof ArrayBuffer?(r=e,o+=T):(r=e.buffer,"[object Int8Array]"===n?o+=M:"[object Uint8Array]"===n?o+=L:"[object Uint8ClampedArray]"===n?o+=F:"[object Int16Array]"===n?o+=z:"[object Uint16Array]"===n?o+=q:"[object Int32Array]"===n?o+=U:"[object Uint32Array]"===n?o+=W:"[object Float32Array]"===n?o+=K:"[object Float64Array]"===n?o+=G:t(Error("Failed to get type for BinaryArray"))),t(o+X(r))}else if("[object Blob]"===n){var i=new FileReader | ||
i.onload=function(){var n=C+e.type+"~"+X(this.result) | ||
t(k+B+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,R)!==k)return JSON.parse(e) | ||
var t,n=e.substring(J),type=e.substring(R,J) | ||
if(type===B&&D.test(n)){var r=n.match(D) | ||
t=r[1],n=n.substring(r[0].length)}var o=Q(n) | ||
switch(type){case T:return o | ||
case B:return i([o],{type:t}) | ||
case L:return new Int8Array(o) | ||
case M:return new Uint8Array(o) | ||
case M:return new Int8Array(o) | ||
case L:return new Uint8Array(o) | ||
case F:return new Uint8ClampedArray(o) | ||
@@ -204,10 +204,10 @@ case z:return new Int16Array(o) | ||
case G:return new Float64Array(o) | ||
default:throw Error("Unkown type: "+type)}},stringToBuffer:X,bufferToString:J} | ||
function Y(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function Z(e,t,n,r,o,i){e.executeSql(n,r,o,function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[name],function(e,c){c.rows.length?i(e,a):Y(e,t,function(){e.executeSql(n,r,o,i)},i)},i):i(e,a)},i)}var $={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null} | ||
default:throw Error("Unkown type: "+type)}},stringToBuffer:Q,bufferToString:X} | ||
function Y(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function Z(e,t,n,r,o,i){e.executeSql(n,r,o,function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[name],function(e,u){u.rows.length?i(e,a):Y(e,t,function(){e.executeSql(n,r,o,i)},i)},i):i(e,a)},i)}var $={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null} | ||
if(e)for(var r in e)n[r]="string"!=typeof e[r]?""+e[r]:e[r] | ||
var o=new a(function(e,r){try{n.db=openDatabase(n.name,n.version+"",n.description,n.size)}catch(e){return r(e)}n.db.transaction(function(o){Y(o,n,function(){t._dbInfo=n,e()},function(e,t){r(t)})},r)}) | ||
return n.serializer=V,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT * FROM "+o.storeName,[],function(n,r){for(var i=r.rows,a=i.length,c=0;c<a;c++){var u=i.item(c),s=u.value | ||
if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()},function(e,t){r(t)})})}).catch(r)}) | ||
return c(r,t),r},getItem:function(e,t){var n=this | ||
o.db.transaction(function(n){Z(n,o,"SELECT * FROM "+o.storeName,[],function(n,r){for(var i=r.rows,a=i.length,u=0;u<a;u++){var c=i.item(u),s=c.value | ||
if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,c.key,u+1)))return void t(s)}t()},function(e,t){r(t)})})}).catch(r)}) | ||
return u(r,t),r},getItem:function(e,t){var n=this | ||
e=s(e) | ||
@@ -217,29 +217,29 @@ var r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
r&&(r=o.serializer.deserialize(r)),t(r)},function(e,t){r(t)})})}).catch(r)}) | ||
return c(r,t),r},setItem:function(e,t,n){return function e(t,n,r,o){var i=this | ||
return u(r,t),r},setItem:function(e,t,n){return function e(t,n,r,o){var i=this | ||
t=s(t) | ||
var u=new a(function(a,c){i.ready().then(function(){void 0===n&&(n=null) | ||
var u=n,s=i._dbInfo | ||
s.serializer.serialize(n,function(n,f){f?c(f):s.db.transaction(function(e){Z(e,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[t,n],function(){a(u)},function(e,t){c(t)})},function(n){if(n.code===n.QUOTA_ERR){if(o>0)return void a(e.call(i,t,u,r,o-1)) | ||
c(n)}})})}).catch(c)}) | ||
return c(u,r),u}.call(this,e,t,n,1)},removeItem:function(e,t){var n=this | ||
var c=new a(function(a,u){i.ready().then(function(){void 0===n&&(n=null) | ||
var c=n,s=i._dbInfo | ||
s.serializer.serialize(n,function(n,f){f?u(f):s.db.transaction(function(e){Z(e,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[t,n],function(){a(c)},function(e,t){u(t)})},function(n){if(n.code===n.QUOTA_ERR){if(o>0)return void a(e.call(i,t,c,r,o-1)) | ||
u(n)}})})}).catch(u)}) | ||
return u(c,r),c}.call(this,e,t,n,1)},removeItem:function(e,t){var n=this | ||
e=s(e) | ||
var r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){r(t)})})}).catch(r)}) | ||
return c(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
return u(r,t),r},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"DELETE FROM "+r.storeName,[],function(){e()},function(e,t){n(t)})})}).catch(n)}) | ||
return c(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
return u(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],function(t,n){var r=n.rows.item(0).c | ||
e(r)},function(e,t){n(t)})})}).catch(n)}) | ||
return c(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
return u(n,e),n},key:function(e,t){var n=this,r=new a(function(t,r){n.ready().then(function(){var o=n._dbInfo | ||
o.db.transaction(function(n){Z(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,n){var r=n.rows.length?n.rows.item(0).key:null | ||
t(r)},function(e,t){r(t)})})}).catch(r)}) | ||
return c(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
return u(r,t),r},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var r=t._dbInfo | ||
r.db.transaction(function(t){Z(t,r,"SELECT key FROM "+r.storeName,[],function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key) | ||
e(r)},function(e,t){n(t)})})}).catch(n)}) | ||
return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments) | ||
return u(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments) | ||
var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName) | ||
var r,o=this | ||
return c(r=e.name?new a(function(t){var r | ||
return u(r=e.name?new a(function(t){var r | ||
r=e.name===n.name?o._dbInfo.db:openDatabase(e.name,"","",0),t(e.storeName?{db:r,storeNames:[e.storeName]}:function(e){return new a(function(t,n){e.transaction(function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(n,r){for(var o=[],i=0;i<r.rows.length;i++)o.push(r.rows.item(i).name) | ||
t({db:e,storeNames:o})},function(e,t){n(t)})},function(e){n(e)})})}(r))}).then(function(e){return new a(function(t,n){e.db.transaction(function(r){function o(e){return new a(function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],function(){t()},function(e,t){n(t)})})}for(var i=[],c=0,u=e.storeNames.length;c<u;c++)i.push(o(e.storeNames[c])) | ||
t({db:e,storeNames:o})},function(e,t){n(t)})},function(e){n(e)})})}(r))}).then(function(e){return new a(function(t,n){e.db.transaction(function(r){function o(e){return new a(function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],function(){t()},function(e,t){n(t)})})}for(var i=[],u=0,c=e.storeNames.length;u<c;u++)i.push(o(e.storeNames[u])) | ||
a.all(i).then(function(){t()}).catch(function(e){n(e)})},function(e){n(e)})})}):a.reject("Invalid arguments"),t),r}} | ||
@@ -249,10 +249,10 @@ function ee(e,t){var n=e.name+"/" | ||
if(e)for(var n in e)t[n]=e[n] | ||
return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=V,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then(function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,c=0;c<i;c++){var u=localStorage.key(c) | ||
if(0===u.indexOf(r)){var s=localStorage.getItem(u) | ||
if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),a++)))return s}}}) | ||
return c(r,t),r},getItem:function(e,t){var n=this | ||
return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=V,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then(function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,u=0;u<i;u++){var c=localStorage.key(u) | ||
if(0===c.indexOf(r)){var s=localStorage.getItem(c) | ||
if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,c.substring(o),a++)))return s}}}) | ||
return u(r,t),r},getItem:function(e,t){var n=this | ||
e=s(e) | ||
var r=n.ready().then(function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e) | ||
return r&&(r=t.serializer.deserialize(r)),r}) | ||
return c(r,t),r},setItem:function(e,t,n){var r=this | ||
return u(r,t),r},setItem:function(e,t,n){var r=this | ||
e=s(e) | ||
@@ -264,48 +264,48 @@ var o=r.ready().then(function(){void 0===t&&(t=null) | ||
else try{localStorage.setItem(a.keyPrefix+e,t),o(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}})})}) | ||
return c(o,n),o},removeItem:function(e,t){var n=this | ||
return u(o,n),o},removeItem:function(e,t){var n=this | ||
e=s(e) | ||
var r=n.ready().then(function(){var t=n._dbInfo | ||
localStorage.removeItem(t.keyPrefix+e)}) | ||
return c(r,t),r},clear:function(e){var t=this,n=t.ready().then(function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n) | ||
return u(r,t),r},clear:function(e){var t=this,n=t.ready().then(function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n) | ||
0===r.indexOf(e)&&localStorage.removeItem(r)}}) | ||
return c(n,e),n},length:function(e){var t=this.keys().then(function(e){return e.length}) | ||
return c(t,e),t},key:function(e,t){var n=this,r=n.ready().then(function(){var t,r=n._dbInfo | ||
return u(n,e),n},length:function(e){var t=this.keys().then(function(e){return e.length}) | ||
return u(t,e),t},key:function(e,t){var n=this,r=n.ready().then(function(){var t,r=n._dbInfo | ||
try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}) | ||
return c(r,t),r},keys:function(e){var t=this,n=t.ready().then(function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o) | ||
return u(r,t),r},keys:function(e){var t=this,n=t.ready().then(function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o) | ||
0===i.indexOf(e.keyPrefix)&&r.push(i.substring(e.keyPrefix.length))}return r}) | ||
return c(n,e),n},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config() | ||
return u(n,e),n},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config() | ||
e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,o=this | ||
return c(r=e.name?new a(function(t){t(e.storeName?ee(e,o._defaultConfig):e.name+"/")}).then(function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t) | ||
return u(r=e.name?new a(function(t){t(e.storeName?ee(e,o._defaultConfig):e.name+"/")}).then(function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t) | ||
0===n.indexOf(e)&&localStorage.removeItem(n)}}):a.reject("Invalid arguments"),t),r}},re=function(e,t){for(var n=e.length,r=0;r<n;){if((o=e[r])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0 | ||
r++}var o,i | ||
return!1},oe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},ce={INDEXEDDB:A,WEBSQL:$,LOCALSTORAGE:ne},ue=[ce.INDEXEDDB._driver,ce.WEBSQL._driver,ce.LOCALSTORAGE._driver],se=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),le={description:"",driver:ue.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1} | ||
function de(e,t){e[t]=function(){var n=arguments | ||
return e.ready().then(function(){return e[t].apply(e,n)})}}function ve(){for(var e=1;e<arguments.length;e++){var t=arguments[e] | ||
if(t)for(var n in t)t.hasOwnProperty(n)&&(arguments[0][n]=oe(t[n])?t[n].slice():t[n])}return arguments[0]}var he=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ce)if(ce.hasOwnProperty(n)){var r=ce[n],o=r._driver | ||
this[n]=o,ie[o]||this.defineDriver(r)}this._defaultConfig=ve({},le),this._config=ve({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return Error("Can't call config() after localforage has been used.") | ||
return!1},oe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},ue={INDEXEDDB:A,WEBSQL:$,LOCALSTORAGE:ne},ce=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],se=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),le={description:"",driver:ce.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1} | ||
function he(e,t){e[t]=function(){var n=arguments | ||
return e.ready().then(function(){return e[t].apply(e,n)})}}function de(){for(var e=1;e<arguments.length;e++){var t=arguments[e] | ||
if(t)for(var n in t)t.hasOwnProperty(n)&&(arguments[0][n]=oe(t[n])?t[n].slice():t[n])}return arguments[0]}var ve=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver | ||
this[n]=o,ie[o]||this.defineDriver(r)}this._defaultConfig=de({},le),this._config=de({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return Error("Can't call config() after localforage has been used.") | ||
for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return Error("Database version must be a number.") | ||
this._config[t]=e[t]}return!("driver"in e&&e.driver)||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new a(function(t,n){try{var r=e._driver,o=Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver") | ||
if(!e._driver)return void n(o) | ||
for(var i=fe.concat("_initStorage"),u=0,s=i.length;u<s;u++){var f=i[u],l=!re(se,f) | ||
for(var i=fe.concat("_initStorage"),c=0,s=i.length;c<s;c++){var f=i[c],l=!re(se,f) | ||
if((l||e[f])&&"function"!=typeof e[f])return void n(o)}!function(){for(var t=function(e){return function(){var t=Error("Method "+e+" is not implemented by the current driver"),n=a.reject(t) | ||
return c(n,arguments[arguments.length-1]),n}},n=0,r=se.length;n<r;n++){var o=se[n] | ||
return u(n,arguments[arguments.length-1]),n}},n=0,r=se.length;n<r;n++){var o=se[n] | ||
e[o]||(e[o]=t(o))}}() | ||
var d=function(n){ie[r]&&console.info("Redefining LocalForage driver: "+r),ie[r]=e,ae[r]=n,t()} | ||
"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}) | ||
return u(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ie[e]?a.resolve(ie[e]):a.reject(Error("Driver not found.")) | ||
return u(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(V) | ||
return u(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then(function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}) | ||
return u(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this | ||
var h=function(n){ie[r]&&console.info("Redefining LocalForage driver: "+r),ie[r]=e,ae[r]=n,t()} | ||
"_support"in e?e._support&&"function"==typeof e._support?e._support().then(h,n):h(!!e._support):h(!0)}catch(e){n(e)}}) | ||
return c(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ie[e]?a.resolve(ie[e]):a.reject(Error("Driver not found.")) | ||
return c(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(V) | ||
return c(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then(function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}) | ||
return c(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this | ||
oe(e)||(e=[e]) | ||
var o=this._getSupportedDrivers(e) | ||
function i(){r._config.driver=r.driver()}function c(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}var s=null!==this._driverSet?this._driverSet.catch(function(){return a.resolve()}):a.resolve() | ||
function i(){r._config.driver=r.driver()}function u(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}var s=null!==this._driverSet?this._driverSet.catch(function(){return a.resolve()}):a.resolve() | ||
return this._driverSet=s.then(function(){var e=o[0] | ||
return r._dbInfo=null,r._ready=null,r.getDriver(e).then(function(e){r._driver=e._driver,i(),r._wrapLibraryMethodsWithReady(),r._initDriver=function(e){return function(){var t=0 | ||
return function n(){for(;t<e.length;){var o=e[t] | ||
return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(c).catch(n)}i() | ||
var u=Error("No available storage method found.") | ||
return r._driverSet=a.reject(u),r._driverSet}()}}(o)})}).catch(function(){i() | ||
return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(u).catch(n)}i() | ||
var c=Error("No available storage method found.") | ||
return r._driverSet=a.reject(c),r._driverSet}()}}(o)})}).catch(function(){i() | ||
var e=Error("No available storage method found.") | ||
return r._driverSet=a.reject(e),r._driverSet}),u(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){ve(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n] | ||
this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)de(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new he | ||
return r._driverSet=a.reject(e),r._driverSet}),c(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){de(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n] | ||
this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)he(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new ve | ||
t.exports=pe},{3:3}]},{},[4])(4)}),a=o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}) | ||
@@ -321,6 +321,32 @@ var n=Object.prototype.toString | ||
r(a) | ||
var c=o(function(e,n){var r=t&&t.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,c)}u((r=r.apply(e,t||[])).next())})},o=t&&t.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
var u=o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}) | ||
var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),o=0,i={},a=r.concat() | ||
for(a[63]="-",a[64]="$";o<65;)o>62&&(i[a[o].charCodeAt(0)]=o),i[r[o].charCodeAt(0)]=o++ | ||
var u=function(e){return{v:e,d:{}}},c=function(e,t,r){for(var o=["","",""],i=4,a=4,u=3,c="",s=[],f=0,l=2,h=0,d="",v=r(0),p=t,y=1;h!==l;)f+=(v>>--p&1)<<h++,0==p&&(p=t,v=r(y++)) | ||
if(2===f)return"" | ||
for(l=8*f+8,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
for(d=n(f),o[3]=d,s.push(d);y<=e;){for(l=u,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
if(f<2){for(l=8+8*f,f=h=0;h!==l;)f+=(v>>--p&1)<<h++,0===p&&(p=t,v=r(y++)) | ||
o[a]=n(f),f=a++,0==--i&&(i=1<<u++)}else if(2==f)return s.join("") | ||
if(f>o.length)return null | ||
c=f<o.length?o[f]:d+d.charAt(0),s.push(c),o[a++]=d+c.charAt(0),d=c,0==--i&&(i=1<<u++)}return""},s=function(e){return function(e,t,n){if(null==e)return[] | ||
var r,o=0,i=0,a=0,c=new Map,s=!0,f=0,l=u(3),h=1,d=4,v=2,p=[],y=0,b=0 | ||
if(e.length){for(a=(f=e.charCodeAt(0))<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++b===t&&(b=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++b===t&&(b=0,p.push(n(y)),y=0) | ||
for(c.set(f,l),i=1;i<e.length;i++)if(f=e.charCodeAt(i),r=l.d[f])l=r | ||
else{if(s)s=!1 | ||
else for(a=l.v,o=0;o<v;o++)y=a>>o&1|y<<1,++b===t&&(b=0,p.push(n(y)),y=0) | ||
if(!c.has(f)){for(0==--h&&(h=1<<v++),a=f<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++b===t&&(b=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++b==t&&(b=0,p.push(n(y)),y=0) | ||
c.set(f,u(d++)),s=!0}l.d[f]=u(d++),0==--h&&(h=1<<v++),l=c.get(f)}if(s)s=!1 | ||
else for(a=l.v,o=0;o<v;o++)y=a>>o&1|y<<1,++b===t&&(b=0,p.push(n(y)),y=0) | ||
if(!c.has(f)){for(0==--h&&(h=1<<v++),a=f<256?0:1,o=0;o<v;o++)y=a>>o|y<<1,++b===t&&(b=0,p.push(n(y)),y=0) | ||
for(a=8+8*a,o=0;o<a;o++)y=f>>o&1|y<<1,++b===t&&(b=0,p.push(n(y)),y=0)}0==--h&&(h=1<<v++)}for(o=0;o<v;o++)y=2>>o&1|y<<1,++b===t&&(b=0,p.push(n(y)),y=0) | ||
return p.push(n(y<<=t-b)),p}(e,16,function(e){return n(e)})} | ||
t.default={compress:function(e){return s(e).join("")},compressToArray:s,decompress:function(e){return null===e?"":""===e?null:c(e.length,16,function(t){return e.charCodeAt(t)})},decompressFromArray:function(e){return null===e?"":0===e.length?null:c(e.length,16,function(t){return e[t].charCodeAt(0)})}}}) | ||
r(u) | ||
var c=o(function(e,n){var r=t&&t.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},o=t&&t.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
return o[1]},trys:[],ops:[]} | ||
return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i | ||
function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.") | ||
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(n)throw new TypeError("Generator is already executing.") | ||
for(;a;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o | ||
@@ -340,25 +366,43 @@ switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i | ||
continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1] | ||
return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}} | ||
return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}} | ||
Object.defineProperty(n,"__esModule",{value:!0}) | ||
var c={driver:[i.INDEXEDDB,i.LOCALSTORAGE],valueMaxLength:5e5,autoClearExpires:!1},u=function(){function e(e){void 0===e&&(e={}) | ||
var t=this | ||
this.cacheConfig=a.extend(e,c),this.cacheInstance=i.createInstance(this.cacheConfig),this.cacheConfig.autoClearExpires&&(window.onbeforeunload=function(e){t.clearExpires()})}return e.prototype.clearExpires=function(){var e=this | ||
return this.cacheInstance.iterate(function(t,n){Promise.all([e.isExpired(t),e.isOverLength(t)]).then(function(t){(t[0]||t[1])&&e.cacheInstance.removeItem(n)})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.isOverLength=function(e){return r(this,void 0,void 0,function(){var t,n | ||
var c={driver:[i.INDEXEDDB,i.LOCALSTORAGE],valueMaxLength:5e5,isCompress:!1},s=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=a.extend(e,c),this.cacheInstance=i.createInstance(this.cacheConfig)}return e.prototype.autoClear=function(){var e=this | ||
return this.cacheInstance.iterate(function(t,n){Promise.all([e.isExpired(t),e.isOverLength(t)]).then(function(t){(t[0]||t[1])&&e.remove(n)})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.isOverLength=function(e){return r(this,void 0,void 0,function(){var t,n | ||
return o(this,function(r){switch(r.label){case 0:return t=this.cacheConfig.valueMaxLength,[4,this.cacheInstance.getSerializer()] | ||
case 1:return n=r.sent(),[2,new Promise(function(r,o){n.serialize(e,function(e,n){n&&o(n),r(e.lenth>(t||0))})})]}})})},e.prototype.dropInstance=function(e){return void 0===e&&(e={}),this.cacheInstance.dropInstance(e)},e.prototype.getItem=function(e){return r(this,void 0,void 0,function(){var t,n,r | ||
return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.cacheInstance.getItem(e)] | ||
case 1:return n=r.sent(),[2,new Promise(function(r,o){n.serialize(e,function(e,n){n&&o(n),r(e.lenth>(t||0))})})]}})})},e.prototype.dropInstance=function(e){return void 0===e&&(e={}),this.cacheInstance.dropInstance(e)},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t,n,r,i | ||
return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,7,,8]),[4,this.getItem(e)] | ||
case 1:return t=o.sent(),[4,this.isExpired(t)] | ||
case 2:return n=o.sent(),t&&t.value?n?(this.cacheInstance.removeItem(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[3,4]:[2,Promise.resolve(null)] | ||
case 3:return r=o.sent(),[2,Promise.reject(r)] | ||
case 4:return[2]}})})},e.prototype.setItem=function(e,t,n){return void 0===n&&(n=-1),r(this,void 0,void 0,function(){return o(this,function(r){return a.isDate(n)?n=n.getTime():a.isNumber(n)&&n>0&&(n=(new Date).getTime()+1e3*n),[2,this.cacheInstance.setItem(e,{value:t,expire:n})]})})},e.prototype.appendItem=function(e,t,n){return void 0===n&&(n=-1),r(this,void 0,void 0,function(){var r,i | ||
return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.cacheInstance.getItem(e)] | ||
case 2:return n=o.sent(),t&&t.value?[3,3]:[2,Promise.resolve(null)] | ||
case 3:return n?(this.remove(e),[2,Promise.resolve(null)]):[3,4] | ||
case 4:return t.value?(r=t.value,this.cacheConfig.isCompress&&(r=JSON.parse(u.default.decompress(t.value))),[4,this.set(e,t.value,t.expire)]):[3,6] | ||
case 5:return o.sent(),[2,Promise.resolve(r)] | ||
case 6:return[3,8] | ||
case 7:return i=o.sent(),[2,Promise.reject(i)] | ||
case 8:return[2]}})})},e.prototype.gets=function(e){return r(this,void 0,void 0,function(){var t,n,r,i | ||
return o(this,function(o){switch(o.label){case 0:t=[],n=0,o.label=1 | ||
case 1:return n<e.length?(i=(r=t).push,[4,this.get(e[n])]):[3,4] | ||
case 2:i.call(r,o.sent()),o.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(t)]}})})},e.prototype.set=function(e,t,n){return void 0===n&&(n=-1),r(this,void 0,void 0,function(){var r,i,c,s | ||
return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.cacheInstance.getSerializer()] | ||
case 1:return o.sent(),r=(new Date).getTime(),a.isDate(n)?n=n.getTime():a.isNumber(n)&&n>0&&(n=r+1e3*n),[4,this.setItem(e,{value:this.cacheConfig.isCompress?u.default.compress(JSON.stringify(t)):t,expire:n,now:r})] | ||
case 2:return i=o.sent(),c=this.cacheConfig.isCompress?JSON.parse(u.default.decompress(i.value)):i.value,[2,Promise.resolve(c)] | ||
case 3:return s=o.sent(),[2,Promise.reject(s)] | ||
case 4:return[2]}})})},e.prototype.append=function(e,t,n){return void 0===n&&(n=-1),r(this,void 0,void 0,function(){var r,i | ||
return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getItem(e)] | ||
case 1:return r=o.sent(),[3,3] | ||
case 2:return i=o.sent(),[2,Promise.reject(i)] | ||
case 3:return r?(a.isArray(t)&&a.isArray(r.value)?t=r.value.concat(t):a.isPlainObject(t)&&a.isPlainObject(r.value)&&(t=a.extend(r.value,t)),[2,this.setItem(e,t,n=n||r.expire)]):[2,this.setItem(e,t,n)]}})})},e.prototype.removeItem=function(e){return this.cacheInstance.removeItem(e)},e.prototype.clear=function(){return this.cacheInstance.clear()},e.prototype.length=function(){return this.cacheInstance.length()},e.prototype.iterate=function(e,t){return void 0===t&&(t=null),this.cacheInstance.iterate(e,t)},e}() | ||
n.default=u}) | ||
case 3:return r?(a.isArray(t)&&a.isArray(r.value)?t=r.value.concat(t):a.isPlainObject(t)&&a.isPlainObject(r.value)&&(t=a.extend(r.value,t)),[2,this.set(e,t,n=n||r.expire)]):[2,this.set(e,t,n)]}})})},e.prototype.has=function(e){return r(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.get(e)] | ||
case 1:return t.sent()?[2,Promise.resolve(!0)]:[2,Promise.resolve(!1)]}})})},e.prototype.remove=function(e){return this.cacheInstance.removeItem(e)},e.prototype.keys=function(){return this.cacheInstance.keys()},e.prototype.clear=function(){return this.cacheInstance.clear()},e.prototype.length=function(){return this.cacheInstance.length()},e.prototype.each=function(e){return r(this,void 0,void 0,function(){var t,n,r,i | ||
return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=[],[4,this.cacheInstance.iterate(function(e,n,r){t.push({key:n,value:e})})] | ||
case 1:for(o.sent(),n=t.sort(function(e,t){return e.value.now-e.value.now}),r=0;r<n.length;r++)e&&e(n[r].value.value,n[r].key,r) | ||
return[2,Promise.resolve(!0)] | ||
case 2:return i=o.sent(),[2,Promise.reject(i)] | ||
case 3:return[2]}})})},e.prototype.getItem=function(e){return this.cacheInstance.getItem(e)},e.prototype.setItem=function(e,t){return r(this,void 0,void 0,function(){return o(this,function(n){return[2,this.cacheInstance.setItem(e,t)]})})},e}() | ||
n.default=s}) | ||
r(c) | ||
var u=o(function(e,n){var r=t&&t.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,c)}u((r=r.apply(e,t||[])).next())})},o=t&&t.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
var s=o(function(e,n){var r=t&&t.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},o=t&&t.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1] | ||
return o[1]},trys:[],ops:[]} | ||
return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i | ||
function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.") | ||
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(n)throw new TypeError("Generator is already executing.") | ||
for(;a;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o | ||
@@ -378,20 +422,27 @@ switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i | ||
continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1] | ||
return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}} | ||
return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}} | ||
Object.defineProperty(n,"__esModule",{value:!0}) | ||
var i=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=a.extend(e,{name:"memcache"}),this.cacheInstance={}}return e.prototype.clearExpires=function(){return r(this,void 0,void 0,function(){var e=this | ||
var i=function(){function e(e){void 0===e&&(e={}),this.cacheConfig=a.extend(e,{name:"memcache"}),this.cacheInstance={}}return e.prototype.autoClear=function(){return r(this,void 0,void 0,function(){var e=this | ||
return o(this,function(t){return Object.keys(this.cacheInstance).forEach(function(t,n){return r(e,void 0,void 0,function(){var e,n | ||
return o(this,function(r){switch(r.label){case 0:return e=this.cacheInstance[t],n=t.replace(this.cacheConfig.name+"/",""),[4,this.isExpired(e)] | ||
case 1:return r.sent()&&this.removeItem(n),[2]}})})}),[2,Promise.resolve(!0)]})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.getKey=function(e){return this.cacheConfig.name+"/"+e},e.prototype.getItem=function(e){return r(this,void 0,void 0,function(){var t,n | ||
case 1:return r.sent()&&this.remove(n),[2]}})})}),[2,Promise.resolve(!0)]})})},e.prototype.isExpired=function(e){return e&&e.expire&&e.expire>0&&e.expire<(new Date).getTime()?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.getKey=function(e){return this.cacheConfig.name+"/"+e},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t,n | ||
return o(this,function(r){switch(r.label){case 0:return e=this.getKey(e),[4,this.isExpired(t=this.cacheInstance[e])] | ||
case 1:return n=r.sent(),t&&t.value?n?(this.removeItem(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[2]:[2,Promise.resolve(null)]}})})},e.prototype.setItem=function(e,t,n){return void 0===n&&(n=-1),e=this.getKey(e),a.isDate(n)?n=n.getTime():a.isNumber(n)&&n>0&&(n=(new Date).getTime()+1e3*n),this.cacheInstance[e]={value:t,expire:n},Promise.resolve(t)},e.prototype.appendItem=function(e,t,n){void 0===n&&(n=-1) | ||
case 1:return n=r.sent(),t&&t.value?n?(this.remove(e),[2,Promise.resolve(null)]):t.value?[2,Promise.resolve(t.value)]:[2]:[2,Promise.resolve(null)]}})})},e.prototype.gets=function(e){return r(this,void 0,void 0,function(){var t,n,r,i | ||
return o(this,function(o){switch(o.label){case 0:t=[],n=0,o.label=1 | ||
case 1:return n<e.length?(i=(r=t).push,[4,this.get(e[n])]):[3,4] | ||
case 2:i.call(r,o.sent()),o.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(t)]}})})},e.prototype.set=function(e,t,n){return void 0===n&&(n=-1),e=this.getKey(e),a.isDate(n)?n=n.getTime():a.isNumber(n)&&n>0&&(n=(new Date).getTime()+1e3*n),this.cacheInstance[e]={value:t,expire:n},Promise.resolve(t)},e.prototype.append=function(e,t,n){void 0===n&&(n=-1) | ||
var r=this.cacheInstance[this.getKey(e)] | ||
return r?(a.isArray(t)&&a.isArray(r.value)?t=r.value.concat(t):a.isPlainObject(t)&&a.isPlainObject(r.value)&&(t=a.extend(r.value,t)),this.setItem(e,t,n=n||r.expire)):this.setItem(e,t,n)},e.prototype.removeItem=function(e){return e=this.getKey(e),this.cacheInstance[e]&&(this.cacheInstance[e]=null,this.cacheInstance=a.omit(this.cacheInstance,e)),Promise.resolve()},e.prototype.clear=function(){return this.cacheInstance={},Promise.resolve()},e.prototype.length=function(){var e=Object.keys(this.cacheInstance) | ||
return e.length?Promise.resolve(e.length):Promise.resolve(0)},e.prototype.iterate=function(e,t){return void 0===t&&(t=null),r(this,void 0,void 0,function(){var n,i,a=this | ||
return o(this,function(c){return i=(n=Object.keys(this.cacheInstance)).length>0?this.cacheInstance[n[n.length-1]].value:null,n.forEach(function(t,n){return r(a,void 0,void 0,function(){var r | ||
return o(this,function(o){switch(o.label){case 0:return t=t.replace(this.cacheConfig.name+"/",""),[4,this.getItem(t)] | ||
case 1:return r=o.sent(),e(r,t,n),[2]}})})}),t&&t(null,i),[2,Promise.resolve(i)]})})},e}() | ||
return r?(a.isArray(t)&&a.isArray(r.value)?t=r.value.concat(t):a.isPlainObject(t)&&a.isPlainObject(r.value)&&(t=a.extend(r.value,t)),this.set(e,t,n=n||r.expire)):this.set(e,t,n)},e.prototype.has=function(e){return this.get(e)?Promise.resolve(!0):Promise.resolve(!1)},e.prototype.remove=function(e){return e=this.getKey(e),this.cacheInstance[e]&&(this.cacheInstance[e]=null,this.cacheInstance=a.omit(this.cacheInstance,e)),Promise.resolve()},e.prototype.keys=function(){return Promise.resolve(Object.keys(this.cacheInstance))},e.prototype.clear=function(){return this.cacheInstance={},Promise.resolve()},e.prototype.length=function(){var e=Object.keys(this.cacheInstance) | ||
return e.length?Promise.resolve(e.length):Promise.resolve(0)},e.prototype.each=function(e){return r(this,void 0,void 0,function(){var t,n,r,i | ||
return o(this,function(o){switch(o.label){case 0:t=Object.keys(this.cacheInstance),n=0,o.label=1 | ||
case 1:return n<t.length?(r=t[n].replace(this.cacheConfig.name+"/",""),[4,this.get(r)]):[3,4] | ||
case 2:i=o.sent(),e&&e(i,r,n),o.label=3 | ||
case 3:return n++,[3,1] | ||
case 4:return[2,Promise.resolve(!0)]}})})},e}() | ||
n.default=i}) | ||
r(u) | ||
var s=o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Persist=c.default,t.Cache=u.default}),f=r(s),l=s.Persist,d=s.Cache | ||
e.default=f,e.Persist=l,e.Cache=d,Object.defineProperty(e,"__esModule",{value:!0})}) | ||
r(s) | ||
var f=o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Persist=c.default,t.Cache=s.default}),l=r(f),h=f.Persist,d=f.Cache | ||
e.default=l,e.Persist=h,e.Cache=d,Object.defineProperty(e,"__esModule",{value:!0})}) | ||
//# sourceMappingURL=mycache.prod.min.js.map |
{ | ||
"name": "mycache", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A Cache library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# Mycache | ||
A cache library | ||
[![Build Status](https://travis-ci.org/arcthur/mycache.svg?branch=master)](http://travis-ci.org/arcthur/mycache) | ||
[![NPM version](https://badge.fury.io/js/mycache.svg)](http://badge.fury.io/js/mycache) | ||
[![Dependency Status](https://img.shields.io/david/arcthur/mycache.svg)](https://david-dm.org/arcthur/mycache) | ||
[![npm](https://img.shields.io/npm/dm/mycache.svg?maxAge=2592000)](https://npmcharts.com/compare/mycache?minimal=true) | ||
Mycache is a cache library enhanced front end local cache. Mycache provides two kinds of cache: persist cache and memory cache. Persist cache uses [localforage](https://github.com/localForage/localForage) to support. | ||
```bash | ||
npm install mycache | ||
``` | ||
## How to use Mycache | ||
### Init cache | ||
```js | ||
import { Cache, Persist } from 'mycache'; | ||
const persist = new Persist(); | ||
``` | ||
And the Promise/Async form: | ||
```js | ||
import { Cache, Persist } from 'mycache'; | ||
const persist = new Persist(); | ||
async function persist() { | ||
await persist.set('key', 'value'); | ||
return await persist.get('key'); | ||
} | ||
``` | ||
### Configuration | ||
Cache Config: | ||
```js | ||
import { Cache } from 'mycache'; | ||
const cache = new Cache({ | ||
name: 'mycache', // name prefix of key | ||
}); | ||
``` | ||
Persist Config: | ||
```js | ||
import { Persist } from 'mycache'; | ||
const persist = new Persist({ | ||
name: 'mycache', // name prefix of key | ||
valueMaxLength: 500 * 1000, // max length of value | ||
storeName: 'persist'; // The name of the datastore | ||
}); | ||
``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
849810
4758
58