MCPcopy Create free account
hub / github.com/firebase/firebase-tools / promiseWhile

Function promiseWhile

src/utils.ts:423–442  ·  view source on GitHub ↗
(
  action: () => Promise<T>,
  check: (value: T) => boolean,
  interval = 2500,
)

Source from the content-addressed store, hash-verified

421 * sync check returns false. Resolves with the value that passed the check.
422 */
423export async function promiseWhile<T>(
424 action: () => Promise<T>,
425 check: (value: T) => boolean,
426 interval = 2500,
427): Promise<T> {
428 return new Promise<T>((resolve, promiseReject) => {
429 const run = async () => {
430 try {
431 const res = await action();
432 if (check(res)) {
433 return resolve(res);
434 }
435 setTimeout(run, interval);
436 } catch (err: unknown) {
437 return promiseReject(err);
438 }
439 };
440 run();
441 });
442}
443
444/**
445 * Return a promise that rejects after timeoutMs but otherwise behave the same.

Callers

nothing calls this directly

Calls 1

runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…