MCPcopy Create free account
hub / github.com/anomalyco/opencode / waitFor

Function waitFor

packages/opencode/test/cli/run/stream.transport.test.ts:31–43  ·  view source on GitHub ↗
(check: () => T | undefined, timeout = 1_000)

Source from the content-addressed store, hash-verified

29}
30
31async function waitFor<T>(check: () => T | undefined, timeout = 1_000): Promise<T> {
32 const end = Date.now() + timeout
33 while (Date.now() < end) {
34 const value = check()
35 if (value !== undefined) {
36 return value
37 }
38
39 await Bun.sleep(10)
40 }
41
42 throw new Error("timed out waiting for value")
43}
44
45function busy(sessionID = "session-1") {
46 return {

Callers 1

Calls 1

checkFunction · 0.50

Tested by

no test coverage detected