after es-toolkit
Creates a new function that invokes the original function starting from the n-th call.
Usage
after(n, func)
Use after when you want to ignore the first few calls and execute the function starting from the n-th call. This is useful when you need to perform an action only after a specific number of occurrences in events or asynchronous operations.
Parameters
The number of calls required before func is executed.
The function to be executed.
Returns
A new function that tracks the number of calls and executes func starting from the n-th call. Returns undefined for calls before the n-th call.
Throws
Throws an error when n is not an integer or is negative.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.