blob: 4e54f770b0b811ce61e1d705bef10a84d6c31b33 (
plain) (
tree)
|
|
import * as _ from '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: number): void {
clearInterval(intervalId);
},
};
|