Function unary

  • Creates a function that accepts up to one argument, ignoring any additional arguments.

    Type Parameters

    • F extends ((...args: any[]) => any)

      The type of the function.

    Parameters

    • func: F

      The function to cap arguments for.

    Returns ((...args: any[]) => ReturnType<F>)

    Returns the new capped function.

      • (...args): ReturnType<F>
      • Parameters

        • Rest...args: any[]

        Returns ReturnType<F>

    function fn(a, b, c) {
    console.log(arguments);
    }

    unary(fn)(1, 2, 3); // [Arguments] { '0': 1 }