Consolidate sleep usages into a tested utility function

This commit is contained in:
Evan Hahn 2020-10-13 17:21:42 -05:00 committed by Scott Nonnenberg
parent c4de9436f3
commit 60f2422e2a
10 changed files with 357 additions and 84 deletions

View file

@ -1,5 +1,7 @@
import PQueue from 'p-queue';
import { sleep } from './sleep';
declare global {
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@ -39,10 +41,6 @@ type BatcherType<ItemType> = {
unregister: () => void;
};
async function sleep(ms: number): Promise<void> {
await new Promise(resolve => setTimeout(resolve, ms));
}
export function createWaitBatcher<ItemType>(
options: BatcherOptionsType<ItemType>
): BatcherType<ItemType> {