blob: 1656318e6da925c323d347ab3627d8ed1d4a475c (
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;
}
});
return intervalId;
},
clearAsyncExcludingInterval(intervalId: number): void {
clearInterval(intervalId);
},
};
|