()
| 18 | }) |
| 19 | |
| 20 | function defer<T = void>() { |
| 21 | let resolve!: (value: T | PromiseLike<T>) => void |
| 22 | let reject!: (error?: unknown) => void |
| 23 | const promise = new Promise<T>((next, fail) => { |
| 24 | resolve = next |
| 25 | reject = fail |
| 26 | }) |
| 27 | |
| 28 | return { promise, resolve, reject } |
| 29 | } |
| 30 | |
| 31 | async function waitFor<T>(check: () => T | undefined, timeout = 1_000): Promise<T> { |
| 32 | const end = Date.now() + timeout |
no outgoing calls
no test coverage detected