@amaui/cache
Version:
7 lines (6 loc) • 12.7 kB
JavaScript
/** @license AmauiCache v1.0.11117
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).AmauiCache=e()}(this,(function(){"use strict";function t(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var e={},r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n={exports:{}};!function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const n={},o="undefined"!=typeof window&&void 0!==window.document,a=!(void 0===r||!t.exports);e.default=function t(e,r,i={}){var s;const c=Object.assign(Object.assign({},n),i),{variant:u}=c,f=r&&"object"==typeof r&&Object.getPrototypeOf(r);switch(e){case"string":return"string"==typeof r;case"number":return"number"==typeof r&&!Number.isNaN(r);case"boolean":return"boolean"==typeof r;case"array":return Array.isArray(r);case"object":return"object"==typeof r&&!!r&&r.constructor===Object;case"object-like":return"object"==typeof r&&(null===r||r.constructor!==Object);case"class":return("object"==typeof r||"function"==typeof r)&&(/class/gi.test(String(r))||/class/gi.test(String(null==r?void 0:r.constructor)));case"function":return!!(r&&r instanceof Function);case"async":return!(!t("function",r)||!(o?"AsyncFunction"===r.constructor.name:r()instanceof Promise));case"map":return!(f!==Map.prototype);case"weakmap":return!(f!==WeakMap.prototype);case"set":return!(f!==Set.prototype);case"weakset":return!(f!==WeakSet.prototype);case"promise":return!(f!==Promise.prototype);case"int8array":return!(f!==Int8Array.prototype);case"uint8array":return!(f!==Uint8Array.prototype);case"uint8clampedarray":return!(f!==Uint8ClampedArray.prototype);case"int16array":return!(f!==Int16Array.prototype);case"uint16array":return!(f!==Uint16Array.prototype);case"int32array":return!(f!==Int32Array.prototype);case"uint32array":return!(f!==Uint32Array.prototype);case"float32array":return!(f!==Float32Array.prototype);case"float64array":return!(f!==Float64Array.prototype);case"bigint64array":return!(f!==BigInt64Array.prototype);case"biguint64array":return!(f!==BigUint64Array.prototype);case"typedarray":return t("int8array",r)||t("uint8array",r)||t("uint8clampedarray",r)||t("int16array",r)||t("uint16array",r)||t("int32array",r)||t("uint32array",r)||t("float32array",r)||t("float64array",r)||t("bigint64array",r)||t("biguint64array",r);case"dataview":return!(f!==DataView.prototype);case"arraybuffer":return!(f!==ArrayBuffer.prototype);case"sharedarraybuffer":return"undefined"!=typeof SharedArrayBuffer&&!(f!==SharedArrayBuffer.prototype);case"symbol":return!("symbol"!=typeof r);case"error":return!!(r&&r instanceof Error);case"date":return!!(r&&r instanceof Date);case"regexp":return!!(r&&r instanceof RegExp);case"arguments":return!(!r||"[object Arguments]"!==r.toString());case"null":return null===r;case"undefined":return void 0===r;case"blob":return o&&r instanceof Blob;case"buffer":return!(!a||"function"!=typeof(null===(s=null==r?void 0:r.constructor)||void 0===s?void 0:s.isBuffer)||!r.constructor.isBuffer(r));case"element":if(r)switch(u){case void 0:case"html":case"element":return o&&("object"==typeof HTMLElement?r instanceof HTMLElement:r&&"object"==typeof r&&null!==r&&1===r.nodeType&&"string"==typeof r.nodeName);case"node":return o&&("object"==typeof Node?r instanceof Node:r&&"object"==typeof r&&null!==r&&"number"==typeof r.nodeType&&"string"==typeof r.nodeName);case"react":return r.elementType||r.hasOwnProperty("$$typeof");default:return!1}return!1;case"simple":return t("string",r,c)||t("number",r,c)||t("boolean",r,c)||t("undefined",r,c)||t("null",r,c);case"not-array-object":return!t("array",r,c)&&!t("object",r,c);default:return!1}}}(n,n.exports);var o={};Object.defineProperty(o,"__esModule",{value:!0});const a=t=>{if((t=>Array.isArray(t))(t))return t.map((t=>a(t)));if((t=>"object"==typeof t&&!!t&&t.constructor===Object)(t)){const e={};return Object.keys(t).forEach((r=>e[r]=a(t[r]))),e}return t};var i=o.default=a,s=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const c=s(n.exports),u=s(o),f={copy:!1,merge:{array:!1}},l=(t,e,r={})=>{const n=Object.assign(Object.assign({},f),r);if(n.merge.array&&(0,c.default)("array",t)&&(0,c.default)("array",e)){const r=Math.max(t.length,e.length);for(let o=0;o<r;o++)void 0===t[o]&&(t[o]=e[o]),((0,c.default)("object",t[o])&&(0,c.default)("object",e[o])||(0,c.default)("array",t[o])&&(0,c.default)("array",e[o]))&&(t[o]=l(t[o],e[o],n))}return(0,c.default)("object",t)&&(0,c.default)("object",e)&&Object.keys(e).forEach((r=>{t.hasOwnProperty(r)?(0,c.default)("object",t[r])&&(0,c.default)("object",e[r])&&(t[r]=l(t[r],e[r],n)):t[r]=n.copy?(0,u.default)(e[r]):e[r]})),t};var p=e.default=l,y={},d={exports:{}},h={exports:{}};!function(t,e){var n;t.exports=(n=n||function(t,e){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r&&r.crypto&&(n=r.crypto),!n)try{n=require("crypto")}catch(t){}var o=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),i={},s=i.lib={},c=s.Base={extend:function(t){var e=a(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(t,r){t=this.words=t||[],this.sigBytes=r!=e?r:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,o=t.sigBytes;if(this.clamp(),n%4)for(var a=0;a<o;a++){var i=r[a>>>2]>>>24-a%4*8&255;e[n+a>>>2]|=i<<24-(n+a)%4*8}else for(var s=0;s<o;s+=4)e[n+s>>>2]=r[s>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r<t;r+=4)e.push(o());return new u.init(e,t)}}),f=i.enc={},l=f.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var a=e[o>>>2]>>>24-o%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n+=2)r[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(r,e/2)}},p=f.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var a=e[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(r,e)}},y=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=y.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,o=n.words,a=n.sigBytes,i=this.blockSize,s=a/(4*i),c=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*i,f=t.min(4*c,a);if(c){for(var l=0;l<c;l+=i)this._doProcessBlock(o,l);r=o.splice(0,c),n.sigBytes-=f}return new u.init(r,f)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});s.Hasher=d.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new h.HMAC.init(t,r).finalize(e)}}});var h=i.algo={};return i}(Math),n)}(h),function(t,e){var r;t.exports=(r=h.exports,function(t){var e=r,n=e.lib,o=n.WordArray,a=n.Hasher,i=e.algo,s=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,o=0;o<64;)e(n)&&(o<8&&(s[o]=r(t.pow(n,.5))),c[o]=r(t.pow(n,1/3)),o++),n++}();var u=[],f=i.SHA256=a.extend({_doReset:function(){this._hash=new o.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],o=r[1],a=r[2],i=r[3],s=r[4],f=r[5],l=r[6],p=r[7],y=0;y<64;y++){if(y<16)u[y]=0|t[e+y];else{var d=u[y-15],h=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[y-2],b=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[y]=h+u[y-7]+b+u[y-16]}var v=n&o^n&a^o&a,w=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),m=p+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&f^~s&l)+c[y]+u[y];p=l,l=f,f=s,s=i+m|0,i=a,a=o,o=n,n=m+(w+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+a|0,r[3]=r[3]+i|0,r[4]=r[4]+s|0,r[5]=r[5]+f|0,r[6]=r[6]+l|0,r[7]=r[7]+p|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return r[o>>>5]|=128<<24-o%32,r[14+(o+64>>>9<<4)]=t.floor(n/4294967296),r[15+(o+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=a._createHelper(f),e.HmacSHA256=a._createHmacHelper(f)}(Math),r.SHA256)}(d);var g={},b=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(g,"__esModule",{value:!0});const v=b(n.exports),w=(t,e)=>{let r=e(t);if(void 0===r)return"";try{(0,v.default)("object-like",r)&&(0,v.default)("not-array-object",r)&&null!==r&&(r=Object.assign({},r))}catch(t){}return(0,v.default)("object",r)?`{${Object.keys(r).sort().map((t=>`"${t}":${w(r[t],e)}`)).filter((t=>":"!==t.slice(-1))).join(",")}}`:(0,v.default)("array",r)?`[${r.map((t=>w(t,e))).filter(Boolean).join(",")}]`:(0,v.default)("string",r)?`"${r}"`:(t=>(0,v.default)("string",t)?t.replace(/(\s|\r|\n)+/," "):t)(JSON.stringify((t=>void 0===t?"undefined":t instanceof Function||t instanceof Object?t.toString():t)(r)))};g.default=t=>{const e=new WeakSet;return w(t,(t=>{if("object"==typeof t&&null!==t){if(e.has(t))return;e.add(t)}return t}))};var m=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(y,"__esModule",{value:!0});const _=m(d.exports),j=m(g),A={serialize:!0,withPrefix:!0};var B=y.default=(t,e={})=>{const r=Object.assign(Object.assign({},A),e);let n=t;return r.serialize&&(n=(0,j.default)(n)),n=(0,_.default)(n).toString(),r.withPrefix?`0x${n}`:n};const x=()=>Math.floor((new Date).getTime()/1e3),O={value:{copy:!1},add:{override:!0}};class S{static get options(){return this.options_}static set options(t){this.options_=p(t,O)}static add(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];const o=B(r);if(!this.caches[o]||this.options.add.override){const e=this.options.value.copy?i(t):t;return this.caches[o]={value:e,added_at:x()},e}}static update(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];const o=B(r);if(this.caches[o]){const e=this.options.value.copy?i(t):t;return this.caches[o].value=e,this.caches[o].updated_at=x(),e}}static get(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const n=B(e);if(this.caches[n])return this.options.value.copy?i(this.caches[n].value):this.caches[n].value}static has(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const n=B(e);return this.caches.hasOwnProperty(n)}static remove(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const n=B(e);this.caches.hasOwnProperty(n)&&delete this.caches[n]}static reset(){this.caches={},this.options=O}}return t(S,"caches",{}),t(S,"options_",O),S}));