UNPKG

async-test-util

Version:

Util-functions that are be useful in async tests

17 lines (15 loc) 433 B
import wait from './wait'; import promisify from './promisify'; export default function runForever(predicate, interval = 100) { let t = 1; // trick optimizers return new Promise(() => { const runLoop = () => { t++; const val = promisify(predicate()); val .then(() => wait(interval)) .then(() => runLoop()); }; runLoop(t); }); }