Function isRetryOK

  • Checks if a RetryResult was successful, i.e. if the ok property is defined.

    Parameters

    Returns result is {
        ok: unknown;
    }

    true if the result was successful, false otherwise.

    Example

    Basic usage

    const result: RetryResult<string>
    if (isRetryOK(result)) {
    console.log(result.ok)
    } else {
    console.error(result.err)
    }

    Type narrowing

    const result: RetryResult<number>
    if (isRetryOK(result)) {
    result.ok // type: number
    } else {
    result.err // type: unknown (probably Error)
    }

    // or
    if (!isRetryOK(result)) {
    result.err // type: unknown (probably Error)
    } else {
    result.ok // type: number
    }

Generated using TypeDoc