nepse-api-helper
Version:
a wrapper to use nepse api easily since they set up weird restrictions
24 lines (23 loc) • 520 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCacheItem = getCacheItem;
exports.setCacheItem = setCacheItem;
function getCacheItem(cache, key) {
const item = cache[key];
if (!item) {
return null;
}
if (Date.now() > item.expiry) {
return null;
}
return item.data;
}
function setCacheItem(cache, key, data, ttlMs) {
return {
...cache,
[key]: {
data,
expiry: Date.now() + ttlMs
}
};
}