executeChunks
Function
The executeChunks
function is designed to execute a specified function multiple times, sequentially in chunks, handling promises, and allowing for delays between each chunk. This can be particularly useful when dealing with large sets of data or when there's a need to manage execution over time.
Import
You can import the executeChunks function in two ways, depending on your preference:
CommonJS (Node.js)
const { executeChunks } = require('sequential-chunks-caller');
ES6 Modules (Browsers, Node.js with ESM)
import { executeChunks } from 'sequential-chunks-caller';
Usage
import { executeChunks } from 'sequential-chunks-caller';
const exampleFunction = (a, b) => { console.log(a + b); return a + b; };
const result = await executeChunks({
functionToExecute: exampleFunction,
totalCalls: 5,
chunkSize: 2,
payloadArray: [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],
delaySeconds: 1
});
License
This project is licensed under the MIT License - see the LICENSE.md file for details