MCPcopy Create free account
hub / github.com/angular/angular / until

Function until

adev/src/app/editor/terminal/terminal.component.spec.ts:56–69  ·  view source on GitHub ↗
(fn: () => T)

Source from the content-addressed store, hash-verified

54});
55
56async function until<T>(fn: () => T): Promise<T> {
57 const timeout = 1000;
58 const start = performance.now();
59 while (true) {
60 const result = fn();
61 if (result) {
62 return result;
63 }
64 if (performance.now() - start > timeout) {
65 throw new Error(`condition not satisfied within ${timeout}ms.`);
66 }
67 await new Promise((r) => setTimeout(r, 1));
68 }
69}

Callers 1

Calls 2

setTimeoutFunction · 0.85
fnFunction · 0.50

Tested by

no test coverage detected