diff options
Diffstat (limited to 'packages/utils/src/interval_utils.ts')
-rw-r--r-- | packages/utils/src/interval_utils.ts | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/packages/utils/src/interval_utils.ts b/packages/utils/src/interval_utils.ts deleted file mode 100644 index 3d0561cd2..000000000 --- a/packages/utils/src/interval_utils.ts +++ /dev/null @@ -1,39 +0,0 @@ -export const intervalUtils = { - setAsyncExcludingInterval( - fn: () => Promise<void>, - intervalMs: number, - onError: (err: Error) => void, - ): NodeJS.Timer { - let isLocked = false; - const intervalId = setInterval(async () => { - if (isLocked) { - return; - } else { - isLocked = true; - try { - await fn(); - } catch (err) { - onError(err); - } - isLocked = false; - } - }, intervalMs); - return intervalId; - }, - clearAsyncExcludingInterval(intervalId: NodeJS.Timer): void { - clearInterval(intervalId); - }, - setInterval(fn: () => void, intervalMs: number, onError: (err: Error) => void): NodeJS.Timer { - const intervalId = setInterval(() => { - try { - fn(); - } catch (err) { - onError(err); - } - }, intervalMs); - return intervalId; - }, - clearInterval(intervalId: NodeJS.Timer): void { - clearInterval(intervalId); - }, -}; |