after<F extends (...args: any[]) => any>(n: number,func: F,): F
Creates a function that only executes starting from the n
-th call.
The provided function will be invoked starting from the n
-th call.
This is particularly useful for scenarios involving events or asynchronous operations where an action should occur only after a certain number of invocations.
- A new function that:
- Tracks the number of calls.
- Invokes
func
starting from then
-th call. - Returns
undefined
if fewer thann
calls have been made.