batched-function
v2.0.1
Published
Batch multiple function calls into a single one
Downloads
3,836
Readme
batched-function
Batch multiple function calls into a single one
Useful for collecting DOM updates.
Install
npm install batched-function
Usage
import batchedFunction from 'batched-function';
const batched = batchedFunction(values => {
console.log(values);
});
batched('🦄');
batched('🌈');
batched('🐻');
// Logs ['🦄', '🌈', '🐻']
API
batchedFunction(function_, options?)
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.
options
Type: object
delay
Type: number
Default: undefined
Delay in milliseconds to wait before calling the function with the values. If undefined
, which is by default, the function is called after Promise.resolve()
.