hexo/node_modules/moize/dist/moize.min.js

3 lines
11 KiB
JavaScript
Raw Normal View History

2023-09-25 15:58:56 +08:00
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("micro-memoize"),require("fast-equals")):"function"==typeof define&&define.amd?define(["micro-memoize","fast-equals"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).moize=n(e.memoize,e.fe)}(this,(function(e,n){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},t.apply(this,arguments)}var r={isDeepEqual:!1,isPromise:!1,isReact:!1,isSerialized:!1,isShallowEqual:!1,matchesArg:void 0,matchesKey:void 0,maxAge:void 0,maxArgs:void 0,maxSize:1,onExpire:void 0,profileName:void 0,serializer:void 0,updateCacheForKey:void 0,transformArgs:void 0,updateExpire:!1};function i(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return"function"==typeof e?"function"==typeof n?function(){e.apply(this,arguments),n.apply(this,arguments)}:e:"function"==typeof n?n:void 0}))}function o(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return"function"==typeof e?"function"==typeof n?function(){return e(n.apply(this,arguments))}:e:"function"==typeof n?n:void 0}))}function a(e,n){for(var t=0;t<e.length;t++)if(e[t].key===n)return t;return-1}function u(e,n){var t="function"==typeof n?n:function(n,t){for(var r=0;r<t.length;r++)if(!e(n[r],t[r]))return!1;return!0};return function(e,n){for(var r=0;r<e.length;r++)if(e[r].length===n.length&&t(e[r],n))return r;return-1}}function s(e,n){return n&&n!==r?t({},e,n,{onCacheAdd:i(e.onCacheAdd,n.onCacheAdd),onCacheChange:i(e.onCacheChange,n.onCacheChange),onCacheHit:i(e.onCacheHit,n.onCacheHit),transformArgs:o(e.transformArgs,n.transformArgs)}):e}function c(e,n,t){try{var r=t||n||"anonymous";Object.defineProperty(e,"name",{configurable:!0,enumerable:!1,value:"moized("+r+")",writable:!0})}catch(e){}}function f(e,n,t){var r=a(e,n);-1!==r&&(clearTimeout(e[r].timeoutId),t&&e.splice(r,1))}function l(e,n){var t=setTimeout(e,n);return"function"==typeof t.unref&&t.unref(),t}function p(e,n){return function(t){var r=t.keys[0],i=a(e,r);~i&&(f(e,r,!1),e[i].timeoutId=l(e[i].expirationMethod,n.maxAge))}}function m(e,n,t,r){var i="number"==typeof n.maxAge&&isFinite(n.maxAge)?function(e,n,t,r){var i=n.maxAge;return function o(s,c,p){var m=s.keys[0];if(-1===a(e,m)){var h=function(){var i=u(t,r)(s.keys,m),a=s.values[i];~i&&(s.keys.splice(i,1),s.values.splice(i,1),"function"==typeof n.onCacheChange&&n.onCacheChange(s,c,p)),f(e,m,!0),"function"==typeof n.onExpire&&!1===n.onExpire(m)&&(s.keys.unshift(m),s.values.unshift(a),o(s,c,p),"function"==typeof n.onCacheChange&&n.onCacheChange(s,c,p))};e.push({expirationMethod:h,key:m,timeoutId:l(h,i)})}}}(e,n,t,r):void 0;return{onCacheAdd:i,onCacheHit:i&&n.updateExpire?p(e,n):void 0}}var h={anonymousProfileNameCounter:1,isCollectingStats:!1,profiles:{}},g=!1;function y(e){e?delete h.profiles[e]:h.profiles={}}function d(e){var n=e.profileName;return function(){n&&!h.profiles[n]&&(h.profiles[n]={calls:0,hits:0}),h.profiles[n].calls++}}function v(e){return function(){var n=h.profiles,t=e.profileName;n[t]||(n[t]={calls:0,hits:0}),n[t].calls++,n[t].hits++}}function x(e){return e.displayName||e.name||"Anonymous "+h.anonymousProfileNameCounter++}function C(e,n){return e?(n/e*100).toFixed(4)+"%":"0.0000%"}function A(e){h.isCollectingStats||g||(console.warn('Stats are not currently being collected, please run "collectStats" to enable them.'),g=!0);var n=h.profiles;if(e){if(!n[e])return{calls:0,hits:0,usage:"0.0000%"};var r=n[e];return t({},r,{usage:C(r.calls,r.hits)})}var i=Object.keys(h.profiles).reduce((function(e,t){return e.calls+=n[t].calls,e.hits+=n[t].hits,e}),{calls:0,hits:0});return t({},i,{profiles:Object.keys(n).reduce((function(e,n){return e[n]=A(n),e}),{}),usage:C(i.calls,i.hits)})}var z={arguments:!0,callee:!0,caller:!0,constructor:!0,length:!0,name:!0,prototype:!0};function S(e,n,t){void 0===t&&(t=[]),Object.getOwnPr
//# sourceMappingURL=moize.min.js.map