with-simple-caching
Version:
A wrapper that makes it simple to add caching to any function
19 lines • 811 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCacheFromCacheOption = void 0;
const type_fns_1 = require("type-fns");
const BadRequestError_1 = require("../../utils/errors/BadRequestError");
/**
* how to extract the with simple caching cache option
*/
const getCacheFromCacheOption = ({ forInput, cacheOption, }) => {
if ((0, type_fns_1.isAFunction)(cacheOption)) {
const foundCache = cacheOption({ fromInput: forInput });
if (!foundCache)
throw new BadRequestError_1.BadRequestError('could not extract cache from input with cache resolution method', { forInput });
return foundCache;
}
return cacheOption;
};
exports.getCacheFromCacheOption = getCacheFromCacheOption;
//# sourceMappingURL=getCacheFromCacheOption.js.map