Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebinsua/then-while
Call an (a)sync function until an (a)sync predicate returns false.
https://github.com/sebinsua/then-while
async predicate promise sync then while
Last synced: about 2 months ago
JSON representation
Call an (a)sync function until an (a)sync predicate returns false.
- Host: GitHub
- URL: https://github.com/sebinsua/then-while
- Owner: sebinsua
- Created: 2017-03-20T17:58:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-21T14:25:46.000Z (almost 8 years ago)
- Last Synced: 2024-04-27T05:04:23.408Z (8 months ago)
- Topics: async, predicate, promise, sync, then, while
- Language: JavaScript
- Size: 43.9 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# `then-while`
> Call an (a)sync function until an (a)sync predicate returns false.By default the behaviour is that of a [do while loop](https://en.wikipedia.org/wiki/Do_while_loop).
## Example
```js
const createThenWhile = 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
```sh
yarn add then-while
```