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

install

npm i apr-whilst

Downloadsweekly downloads

2

version

3.0.3

license

MIT

homepage

apr.js.org

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability