const orResult: Result<number, string> = ok(42);
const errorResult: Result<number, string> = error("An error occurred");
orResult.get(); // Returns 42
errorResult.get(); // Throws Error("An error occurred")
orResult.extract(); // Returns {value: 42}
errorResult.extract(); // Returns {error: "An error occurred"}
orResult.toOptional(); // Optional with value 42
errorResult.toOptional(); // Optional with no value
version 1.2.0
Manuel Santos ney.br.santos@gmail.com
Generated using TypeDoc
Represents the result of an operation that can either succeed with a value or fail with an error.