Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Module utils/result

    Result<T, E> — discriminated-union return type for fallible operations.

    Many places in the data layer return T | undefined or T | null to mean both "missing optional thing" and "real failure" — the caller can't tell the cases apart, and the error context is lost. Result makes the distinction explicit:

    const r = await store.get(key); if (isOk(r)) use(r.value); else if (r.error === 'Missing') skipQuietly(); else surfaceError(r.error);

    The error type defaults to string (suitable for tagged unions like 'Missing' | 'Network' | 'Corrupt') but can be any type — including a structured error object that carries a cause / stack.

    Ok
    Err
    Result
    ok
    err
    isOk
    isErr
    match
    mapOk
    mapErr
    unwrap
    unwrapOr
    tryAsync