MCPcopy Create free account
hub / github.com/Noumena-Network/code / waitUntil

Function waitUntil

src/services/api/metricsOptOut.test.ts:210–222  ·  view source on GitHub ↗
(
  predicate: () => boolean,
  timeoutMs = 1000,
)

Source from the content-addressed store, hash-verified

208}
209
210async function waitUntil(
211 predicate: () => boolean,
212 timeoutMs = 1000,
213): Promise<void> {
214 const deadline = Date.now() + timeoutMs
215 while (Date.now() < deadline) {
216 if (predicate()) {
217 return
218 }
219 await new Promise(resolve => setTimeout(resolve, 10))
220 }
221 throw new Error('Timed out waiting for background refresh')
222}
223
224beforeAll(async () => {
225 tempConfigDir = await mkdtemp(join(tmpdir(), 'ncode-metrics-opt-out-test-'))

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected