export type Options = { /** How long to wait in milliseconds before calling the function. If `undefined`, which is by default, the function is called in the next [microtask](https://javascript.info/microtask-queue). If `function_` returns a promise, the next batch will run after whichever of the delay or promise takes longer. @type number */ delay?: number; }; /** Batch multiple function calls into a single one. 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. @param function_ - Function to be called with the values. @example ``` import batchedFunction from 'batched-function'; const batched = batchedFunction(values => { console.log(values); }); batched('🦄'); batched('🌈'); batched('🐻'); // Logs ['🦄', '🌈', '🐻'] ``` */ export default function batchedFunction(function_: (value: ValueType[]) => unknown, { delay }?: Options): (value: ValueType) => void;