apr-whilst

3.0.3 • Public • Published

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

Package Sidebar

Install

npm i apr-whilst

Weekly Downloads

2

Version

3.0.3

License

MIT

Last publish

Collaborators

  • ramitos