Function callOrGet

  • If value is a function then it is called, otherwise the value is returned as is.

    Type Parameters

    • T

      The returned value.

    Parameters

    • value: T | (() => T)

      The value to return or a callback to call.

    Returns T

    The value or the call result.

  • If value is a function then it is called with the given argument, otherwise the value is returned as is.

    Type Parameters

    • T

      The returned value.

    • A

      The value callback argument.

    Parameters

    • value: T | ((arg) => T)

      The value to return or a callback to call.

    • arg: A

      The of argument to pass to the value callback.

    Returns T

    The value or the call result.