ifElseMd.js
375 Bytes
module.exports = (predict, ifTrueFn, elseFn) => {
if (!ifTrueFn) {
ifTrueFn = (req, res, next) => next();
}
if (!elseFn) {
elseFn = (req, res, next) => next();
}
return (req, res, next) => {
if (predict(req, res)) {
ifTrueFn(req, res, next);
} else {
elseFn(req, res, next);
}
};
};