const result: Result<number, "error"> = err("error");
const value: number | "error" = unwrapEither(result); // "error"
const result: Promise<Result<number, string>> = Promise.resolve(ok(1));
const value: Promise<1 | string> = unwrapEither(result); // Promise<1>
Unwrap a result and return either the data or the error. You probably shouldn't use this function and use unwrap or unwrapErr instead.
If the result is an Ok, it will return the data.
If the result is an Err, it will return the error.
const result: Result<number, "error"> = err("error");
const value: number | "error" = unwrapEither(result); // "error"
const result: Promise<Result<number, string>> = Promise.resolve(ok(1));
const value: Promise<1 | string> = unwrapEither(result); // Promise<1>
Unwrap a result and return either the data or the error. You probably shouldn't use this function and use unwrap or unwrapErr instead.
If the result is an Ok, it will return the data.
If the result is an Err, it will return the error.
const result: Result<number, "error"> = err("error");
const value: number | "error" = unwrapEither(result); // "error"
const result: Promise<Result<number, string>> = Promise.resolve(ok(1));
const value: Promise<1 | string> = unwrapEither(result); // Promise<1>
Unwrap a result and return either the data or the error. You probably shouldn't use this function and use unwrap or unwrapErr instead.
If the result is an Ok, it will return the data.
If the result is an Err, it will return the error.
const result: Result<number, "error"> = err("error");
const value: number | "error" = unwrapEither(result); // "error"
const result: Promise<Result<number, string>> = Promise.resolve(ok(1));
const value: Promise<1 | string> = unwrapEither(result); // Promise<1>
Unwrap a result and return either the data or the error. You probably shouldn't use this function and use unwrap or unwrapErr instead.
If the result is an Ok, it will return the data.
If the result is an Err, it will return the error.
const result: Result<number, "error"> = err("error");
const value: number | "error" = unwrapEither(result); // "error"
const result: Promise<Result<number, string>> = Promise.resolve(ok(1));
const value: Promise<1 | string> = unwrapEither(result); // Promise<1>
Unwrap a result and return either the data or the error. You probably shouldn't use this function and use unwrap or unwrapErr instead.
If the result is an Ok, it will return the data.
If the result is an Err, it will return the error.
const result: Result<number, "error"> = err("error");
const value: number | "error" = unwrapEither(result); // "error"
const result: Promise<Result<number, string>> = Promise.resolve(ok(1));
const value: Promise<1 | string> = unwrapEither(result); // Promise<1>
Unwrap a result and return either the data or the error. You probably shouldn't use this function and use unwrap or unwrapErr instead.
If the result is an
Ok, it will return the data.If the result is an
Err, it will return the error.