A function taking a set of items. It should remove items from the set, usually before processing them. (So that the batch won't perpetually block on that item in case of a persistent error.) If the processing function doesn't remove all items from the set, another processing pass will be done later. (This allows you to rate-limit processing, so as not to hog the current thread.)
Optional
sched: ((cb: (() => unknown)) => unknown)A single-argument scheduling function (like requestAnimationFrame, setImmediate, or queueMicrotask). The batch will call it from time to time with a single callback. The scheduling function should then arrange for that callback to be invoked once at some future point, when it is the desired time for pending items to be processed. If no function is given (or it's undefined/null), defer is used.
a Batch that items can be added to for later processing.
Create a batch processing queue from the given processing loop and scheduling function.