repeat-until-async
Repeats the async function The library provides TypeScript definitions. No dependencies needed. Please be sure that your environment has Promise support (or has a polyfill).
Installation
$ npm install repeat-
Usage
The simple use case is described below:
const repeatUntil = ; const timeOfStart = Date; // Wait for some async operation to end;
async/await
The library is async/await compatible because it uses Promises/A+, so the example above could be rewritten:
const repeatUntil = ; const timeOfStart = Date; // Wait for some async operation to endtry const result = await ; // Here are the operations to be done after predicate console; catch error // Here are the operations to be done if predicate didn't succeed in the timeout console;
Supported arguments
/** * Waits for predicate to be truthy and resolves a Promise * * @param predicate Function Predicate that checks the condition * @param timeout Number Maximum wait interval, optional, 5000ms by default * @param interval Number Wait interval, optional, 50ms by default * @return Promise Promise to return a callback result */: Promise;
Build
No building required, library is implemented with ES5 for better compatibility and shipped as is.
License
Library is shipped "as is" under MIT License.
Contributing
Feel free to contribute. Just raise ann issue, create a pull request covering it and don't forget to test everything properly.