package
Batch multiple function calls into a single one
npm install batched-functionGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
5.6 kB
Includes dependencies.
Batch multiple function calls into a single one
Useful for collecting DOM updates.
npm install batched-functionimport batchedFunction from 'batched-function';
const batched = batchedFunction(values => {
console.log(values);
});
batched('🦄');
batched('🌈');
batched('🐻');
// Logs ['🦄', '🌈', '🐻']After a value is passed, function_ is called interval milliseconds later with an array of all the values passed in that time, including the first one.
If function_ returns a promise, the next batch will run after whichever of the delay or promise takes longer.
Type: object
Type: number
Default: undefined
How long to wait in milliseconds before calling the function. If undefined, which is by default, the function is called in the next microtask.