npm.io
0.1.0 • Published 9 years ago

then-while

Licence
MIT
Version
0.1.0
Deps
3
Vulns
0
Weekly
0
Stars
3

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

Keywords