I have a function in which I'd like several setInterval calls, however the code within in them is very similar.
Does anyone have any ideas on how I could better write this to avoid code duplication:
(async (): Promise<void> => {
// 1 min interval check
const oneMin = setInterval(async function () {
Detail.find({ interval: 1 }, async function (err, toCheck) {
// The Same Logic
})
}, minutesToMS(1));
// 10 min interval check
const tenMin = setInterval(async function () {
Detail.find({ interval: 10 }, async function (err, toCheck) {
// The Same Logic
})
}, minutesToMS(10));
})();
Any ideas appreciated.
Thanks.