decord/source/708_memoize.js

42 lines
1 KiB
JavaScript
Raw Normal View History

2026-07-20 16:05:17 +00:00
// Module ID: 708
2026-07-25 08:10:48 +00:00
// Function ID: 8729
2026-07-20 16:05:17 +00:00
// Name: memoize
2026-07-23 10:11:24 +00:00
// Dependencies: [709]
2026-07-20 16:05:17 +00:00
// Module 708 (memoize)
function memoize(arg0, arg1) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-07-20 16:05:17 +00:00
const dependencyMap = arg1;
if ("function" === typeof arg0) {
function memoized() {
const self = this;
2026-07-23 10:11:24 +00:00
if (callback2) {
let applyResult = callback2(...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-20 16:05:17 +00:00
memoized.cache = cache.set(applyResult, applyResult1) || cache;
return applyResult1;
}
}
2026-07-23 10:11:24 +00:00
let Cache = memoized.Cache;
2026-07-20 16:05:17 +00:00
if (!Cache) {
2026-07-23 10:11:24 +00:00
Cache = _require(709);
2026-07-20 16:05:17 +00:00
}
const prototype = Cache.prototype;
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;