Function expectOrThrow

  • Assert that a value is available. Throw an error with the specified message if the provided value is null or undefined

    Returns

    the value

    Example

    expectOrThrow(1) === 1
    

    Example

    expectOrThrow(null) // throws error
    

    Example

    expectOrThrow(null, ':(') // throws error w/ message ':('
    

    Type Parameters

    • T

    Parameters

    • t: undefined | null | T
    • message: string = 'Expected argument to be defined'

    Returns T

Generated using TypeDoc