MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / waitFor

Function waitFor

packages/server/test/ws-broadcast.e2e.test.ts:425–432  ·  view source on GitHub ↗

Spin until `cond()` returns true or 2s elapses.

(cond: () => boolean)

Source from the content-addressed store, hash-verified

423
424/** Spin until `cond()` returns true or 2s elapses. */
425async function waitFor(cond: () => boolean): Promise<void> {
426 const deadline = Date.now() + 2000;
427 while (Date.now() < deadline) {
428 if (cond()) return;
429 await new Promise((r) => setTimeout(r, 10));
430 }
431 throw new Error('waitFor: condition not satisfied within 2000ms');
432}

Callers 1

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected