Files
lan-manager/web/node_modules/@antv/util/esm/memoize.js
openclaw 0a5f6a8047 Initial commit: Lan-manager project code
- Go backend (server/)
- Frontend (web/, server/static/)
- Database and deployment files
- Scripts and docs

Co-Authored-By: 狸花猫/Claude-Qwen3.6-Plus 🐾
2026-04-20 00:52:58 +08:00

31 lines
933 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import isFunction from './is-function';
/**
* _.memoize(calColor);
* _.memoize(calColor, (...args) => args[0]);
* @param f
* @param resolver
*/
export default (function (f, resolver) {
if (!isFunction(f)) {
throw new TypeError('Expected a function');
}
var memoized = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// 使用方法构造 key如果不存在 resolver则直接取第一个参数作为 key
var key = resolver ? resolver.apply(this, args) : args[0];
var cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = f.apply(this, args);
// 缓存起来
cache.set(key, result);
return result;
};
memoized.cache = new Map();
return memoized;
});
//# sourceMappingURL=memoize.js.map