mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 03:32:58 +03:00
ec1a55850c
* feat(ary/unary): implement ary/unary * fix --------- Co-authored-by: Sojin Park <raon0211@toss.im>
554 B
554 B
unary
Creates a function that accepts up to one argument, ignoring any additional arguments.
Signature
function unary<F extends (...args: any[]) => any>(func: F): (...args: any[]) => ReturnType<F>;
Parameters
func
(F
): The function to cap arguments for.
Returns
((...args: any[]) => ReturnType<F>
): Returns the new capped function.
Examples
import { unary } from 'es-toolkit/function';
function fn(a, b, c) {
console.log(arguments);
}
unary(fn)(1, 2, 3); // [Arguments] { '0': 1 }