Creates a funnel that controls the timing and execution of callback. Its main purpose is to manage multiple consecutive (usually fast-paced) calls, reshaping them according to a defined batching strategy and timing policy. This is useful when handling uncontrolled call rates, such as DOM events or network traffic. It can implement strategies like debouncing, throttling, batching, and more.
An optional reducer function can be provided to allow passing data to the callback via calls to call (otherwise the signature of call takes no arguments).
Typing is inferred from callbacks param, and from the rest params that the optional reducer function accepts. Use explicit types for these to ensure that everything else is well-typed.
Notice that this function constructs a funnel object, and does not execute anything when called. The returned object should be used to execute the funnel via its call method.
Debouncing: use minQuietPeriodMs and any triggerAt.
Throttling: use minGapMs and triggerAt: "start" or "both".