kafka-ts
Version:
**KafkaTS** is a Apache Kafka client library for Node.js. It provides both a low-level API for communicating directly with the Apache Kafka cluster and high-level APIs for publishing and subscribing to Kafka topics.
20 lines (19 loc) • 510 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cached = void 0;
const cached = (func, createKey) => {
const cache = {};
const cachedFunc = ((...args) => {
const key = createKey(...args);
if (!(key in cache)) {
cache[key] = func(...args);
}
return cache[key];
});
cachedFunc.clear = () => {
for (const key in cache)
delete cache[key];
};
return cachedFunc;
};
exports.cached = cached;