unary es-toolkit
Creates a new function that limits a function to accept only the first parameter.
Usage
unary(func)
Use unary when you want to limit a function to accept only one parameter. Any additional parameters passed are ignored.
This is useful for preventing callback functions from receiving more parameters than expected in array methods like map, filter, and forEach.
It's also useful in function composition.
Parameters
funcFrequired
The function to limit to accept only the first parameter.
Returns
Returns a new function that passes only the first parameter 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.