blob: 66451800fd45bf64510d7e17c622cefec65ca0cc (
plain) (
tree)
|
|
import {_} from '../utils/lodash';
export const intervalUtils = {
setAsyncExcludingInterval(fn: () => Promise<void>, intervalMs: number) {
let locked = false;
const intervalId = setInterval(async () => {
if (locked) {
return;
} else {
locked = true;
await fn();
locked = false;
}
}, intervalMs);
return intervalId;
},
clearAsyncExcludingInterval(intervalId: NodeJS.Timer): void {
clearInterval(intervalId);
},
};
|