Function constant

Returns a function that always returns the provided value.

const alwaysOne = constant(1);
console.log(alwaysOne()); // 1
  • Type Parameters

    • V

      The type of the value.

    Parameters

    • value: V

      The value to be returned by the constant function.

    Returns Constant<V>

    A function that always returns the provided value.