MCPcopy Create free account
hub / github.com/TanStack/query / waitFor

Function waitFor

packages/lit-query/scripts/l3-stress.mjs:44–52  ·  view source on GitHub ↗
(assertion, timeoutMs = 3000)

Source from the content-addressed store, hash-verified

42}
43
44async function waitFor(assertion, timeoutMs = 3000) {
45 const startedAt = Date.now()
46 while (!assertion()) {
47 if (Date.now() - startedAt > timeoutMs) {
48 throw new Error(`Timed out waiting for assertion after ${timeoutMs}ms`)
49 }
50 await new Promise((resolve) => setTimeout(resolve, 5))
51 }
52}
53
54async function run(cycles = 1000) {
55 const client = new QueryClient({

Calls

no outgoing calls

Tested by

no test coverage detected