@daysnap/utils
Version:
14 lines (10 loc) • 350 B
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});// src/cached.ts
function cached(fn) {
const cache = /* @__PURE__ */ Object.create(null);
return function cachedFn(...args) {
const key = JSON.stringify(args);
const hit = cache[key];
return hit || (cache[key] = fn(...args));
};
}
exports.cached = cached;