logo

wfp

The wfp function stands for wait for promise. It takes a function that returns a promise and waits for it to resolve to a truthy value or an error.

import { wfp } from '@aracna/core';

(async () => {
  await wfp(async () => {
    let random;

    random = Math.random();
    console.log(random);

    return random > 0.5;
  });

  console.log('condition met');
})();