UNPKG

@blackglory/wait-for

Version:

A module for waiting for things to happen.

10 lines (8 loc) 255 B
import { delay } from 'extra-promise' export async function waitForFunction<T>(fn: () => T | PromiseLike<T>, interval: number = 0): Promise<T> { while (true) { const result = await fn() if (result) return result await delay(interval) } }