Function default

  • Creates a matcher that will match to either Ok or Err Results.

    Type Parameters

    • TResult

    • TError

    • TMatchResult

    Parameters

    Returns Matcher<TResult, TError, TMatchResult>

    A matcher that can be used in the Result match function.

    @example: Here's a simple example:

    const result = await try$(primeAsync());
    const message = result.match(
    when(Ok, (num) => `${num} is prime!`),
    when(Err, (err) => `Failed to make a prime number with Error: ${err}`)
    );
    console.log(message);

    Remarks

    See the Result matching for more details.

Generated using TypeDoc