3.0.3 • Published 6 years ago

apr-whilst v3.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

whilst

Repeatedly call fn, while test returns true.

npm.io npm.io

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