with-simple-caching
Version:
A wrapper that makes it simple to add caching to any function
26 lines • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultShouldBypassSetMethod = exports.defaultShouldBypassGetMethod = exports.defaultValueDeserializationMethod = exports.defaultValueSerializationMethod = exports.defaultKeySerializationMethod = exports.noOp = void 0;
const noOp = (value) => value;
exports.noOp = noOp;
const defaultKeySerializationMethod = ({ forInput, }) => JSON.stringify(forInput);
exports.defaultKeySerializationMethod = defaultKeySerializationMethod;
exports.defaultValueSerializationMethod = exports.noOp;
exports.defaultValueDeserializationMethod = exports.noOp;
const defaultShouldBypassGetMethod = () => {
if (process.env.CACHE_BYPASS_GET)
return process.env.CACHE_BYPASS_GET === 'true';
if (process.env.CACHE_BYPASS)
return process.env.CACHE_BYPASS === 'true';
return false;
};
exports.defaultShouldBypassGetMethod = defaultShouldBypassGetMethod;
const defaultShouldBypassSetMethod = () => {
if (process.env.CACHE_BYPASS_SET)
return process.env.CACHE_BYPASS_SET === 'true';
if (process.env.CACHE_BYPASS)
return process.env.CACHE_BYPASS === 'true';
return false;
};
exports.defaultShouldBypassSetMethod = defaultShouldBypassSetMethod;
//# sourceMappingURL=defaults.js.map