rest es-toolkit
Creates a new function that bundles parameters from a specific index into an array and passes them to the function.
Usage
rest(func, startIndex?)
Use rest when you want to bundle the remaining parameters into an array. Parameters before the specific index are passed individually, and parameters after are bundled into an array.
This is useful for creating functions that accept variable parameters or when you want to change how existing functions handle parameters.
It also handles cases where there are fewer parameters.
Parameters
The function to change parameter handling.
The index from which to start bundling into an array. Defaults to func.length - 1, bundling from the last parameter.
Returns
Returns a new function that bundles parameters from a specific index into an array and passes them to the original function.
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.