MCPcopy Create free account
hub / github.com/cloudflare/computer / waitFor

Function waitFor

packages/computerd/src/cli/computerd.test.ts:478–485  ·  view source on GitHub ↗
(predicate, { timeoutMs = 2_000, intervalMs = 10 } = {})

Source from the content-addressed store, hash-verified

476}
477
478async function waitFor(predicate, { timeoutMs = 2_000, intervalMs = 10 } = {}) {
479 const deadline = Date.now() + timeoutMs;
480 while (Date.now() < deadline) {
481 if (predicate()) return;
482 await delay(intervalMs);
483 }
484 throw new Error("waitFor: predicate did not become true within the timeout");
485}
486
487function postJson(url, body) {
488 const payload = JSON.stringify(body);

Callers 2

computerd.test.tsFile · 0.85
App.test.tsxFile · 0.85

Calls 1

delayFunction · 0.85

Tested by

no test coverage detected