then-while

0.1.0 • Public • Published

then-while

Call an (a)sync function until an (a)sync predicate returns false.

Example

const thenWhile = require('then-while')

const predicate = value => Promise.resolve(value < 0.5)
const performStep = message => Promise.resolve(`${(Math.random())}`)

const generateNumber = createThenWhile(predicate, performStep)

generateNumber('some arguments')
  .then(randomNumber => console.log('random number:', randomNumber))

Install

yarn add then-while

Package Sidebar

Install

npm i then-while

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • sebinsua