• Category

    Create a new function taht calls the provided fn and then inverts the sign of the result.

    Time complexity: O(1)

    Space complexity: O(1)

    Type Parameters

    Parameters

    • fn: T

      Function to invert return value of

    Returns T

    The inverted return value of fn

    Higher order

    Example

    function sort(a, b) {
    return a - b;
    }

    const inverted = invert(sort);

    inverted(10, 5); // -5