Files
pezkuwi-api/packages/metadata-builders/dist/esm/with-cache.mjs
T
pezkuwichain 31467f90d4 feat: add PAPI rebrand packages
- @pezkuwi/papi-utils (rebrand of @polkadot-api/utils)
- @pezkuwi/bizinikiwi-bindings (rebrand of @polkadot-api/substrate-bindings)
- @pezkuwi/metadata-builders (rebrand of @polkadot-api/metadata-builders)
- @pezkuwi/merkleize-metadata (rebrand of @polkadot-api/merkleize-metadata)

All @polkadot-api references replaced with @pezkuwi equivalents.
2026-01-22 15:40:12 +03:00

20 lines
582 B
JavaScript

const withCache = (fn, onEnterCircular, onExitCircular) => (input, cache, stack, ...rest) => {
const { id } = input;
if (cache.has(id)) return cache.get(id);
if (stack.has(id)) {
const res = onEnterCircular(() => cache.get(id), input, ...rest);
cache.set(id, res);
return res;
}
stack.add(id);
let result = fn(input, cache, stack, ...rest);
stack.delete(id);
if (cache.has(id))
result = onExitCircular(result, cache.get(id), input, ...rest);
cache.set(id, result);
return result;
};
export { withCache };
//# sourceMappingURL=with-cache.mjs.map