apr-whilst
v3.0.3
Published
Repeatedly call fn, while test returns true.
Downloads
8
Maintainers
Readme
whilst
Repeatedly call fn
, while test
returns true.
Parameters
Examples
import whilst from 'apr-whilst';
const then = (v) => new Promise((resolve) => resolve(v));
const maxCalls = 10;
let calls = 0;
const output = await whilst(async () => {
await then();
return (calls += 1) < maxCalls;
}, async () => (
await then(calls)
);
// output = 10
Returns Promise