promise-chunk-generator
An async generator that takes an array of promise executor functions and creates promises in chunks with fault-tolerance
Installation
npm install promise-chunk-generator
Basic Example:
const promiseChunkGenerator = ; const concurrency = 5; // how many promises you want to run concurrenty, default: 1 let promiseExecutors = ; // array of executor functions, each to pass in new Promise(executor) for let i = 0; i < 3; i++ const promiseExecutor = { console; const timeout = Math; const timeoutId = ; }; promiseExecutors; const options = promiseExecutors concurrency; // Inside an async function...const generator = await ; while true const object = await generatornext; if objectdone break; console;
All Options:
const promiseChunkGenerator = ; const options = promiseExecutors // array of functions to pass in new Promise(executor) concurrency // how many promises you want to run concurrenty, default: 1 perChunkTimeoutDuration // default: 5 * 60 * 1000 ms perPromiseTimeoutDuration // default: 2 * 60 * 1000 ms promiseTimeoutFunction // pass if you want to customize it, see: src/promise-timeout.js promiseCatchFunction // pass if you want to customize it, see: src/promise-catch-function.js promiseChunkCatchFunction // pass if you want to customize it, see: src/promise-chunk-catch-function.js returnRejectedPromiseExecutor // default: true; // Inside an async function...const generator = await ;