logo

wf

The wf function stands for wait for. It takes a function and waits for it to return a truthy value or an error.

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

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

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

    return random > 0.5;
  });

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