Consolidate sleep
usages into a tested utility function
This commit is contained in:
parent
c4de9436f3
commit
60f2422e2a
10 changed files with 357 additions and 84 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue