MCPcopy
hub / github.com/node-cron/node-cron / waitFor

Function waitFor

src/tasks/background-scheduled-task/daemon.test.ts:341–348  ·  view source on GitHub ↗
(get: () => T, timeout = 3000, interval = 25)

Source from the content-addressed store, hash-verified

339// Polls `get` until it returns a truthy value or the timeout elapses, instead
340// of sleeping a fixed amount and hoping the (real-timer) fire already happened.
341async function waitFor<T>(get: () => T, timeout = 3000, interval = 25): Promise<T> {
342 const deadline = Date.now() + timeout;
343 for (;;) {
344 const value = get();
345 if (value || Date.now() > deadline) return value;
346 await new Promise(r => setTimeout(r, interval));
347 }
348}

Callers 1

daemon.test.tsFile · 0.85

Calls 1

getFunction · 0.85

Tested by

no test coverage detected