decord/source/731_memoize.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2026-07-29 08:29:29 +00:00
// Module ID: 731
// Function ID: 732
2026-07-20 16:05:17 +00:00
// Name: memoize
2026-07-29 08:29:29 +00:00
// Dependencies: [732]
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
// Module 731 (memoize)
2026-08-04 21:03:28 +00:00
function memoize(fn, fn2) {
const _require = fn;
const dependencyMap = fn2;
if (typeof fn === "function") {
2026-07-20 16:05:17 +00:00
function memoized() {
const self = this;
2026-07-29 08:29:29 +00:00
if (closure_1) {
let applyResult = obj(...arguments);
2026-07-20 16:05:17 +00:00
} else {
applyResult = arguments[0];
}
const cache = memoized.cache;
if (cache.has(applyResult)) {
return cache.get(applyResult);
} else {
2026-07-23 10:11:24 +00:00
const applyResult1 = callback(...arguments);
2026-07-29 08:29:29 +00:00
tmp4.cache = cache.set(applyResult, applyResult1) || cache;
2026-07-20 16:05:17 +00:00
return applyResult1;
}
2026-07-29 08:29:29 +00:00
obj = closure_1;
tmp4 = memoized;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let Cache = memoized.Cache;
2026-07-20 16:05:17 +00:00
if (!Cache) {
2026-07-29 08:29:29 +00:00
Cache = _require(732);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let cache = new Cache();
2026-07-20 16:05:17 +00:00
memoized.cache = cache;
return memoized;
}
const typeError = new TypeError("Expected a function");
throw typeError;
}
2026-07-23 10:11:24 +00:00
memoize.Cache = require("MapCache");
2026-07-20 16:05:17 +00:00
export default memoize;