UNPKG

insomnia-plugin-valorant

Version:
22 lines 723 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cacheResult = void 0; /** * Caches the result of a function for a given amount of time * @param cacheTimeMS the amount of time to cache the result for in milliseconds * @param func the function to cache the result of */ function cacheResult(cacheTimeMS, func) { let cache = undefined; return (...args) => { if (cache !== undefined && cache.expires > Date.now()) return cache.result; cache = { result: func(...args), expires: Date.now() + cacheTimeMS }; return cache.result; }; } exports.cacheResult = cacheResult; //# sourceMappingURL=cache-result.js.map