import { type Result } from "https://deno.land/x/funky@v0.3.2/mod.ts";
Represents a runtime-safe result of an operation. The operation might be successful, in which case a Result
instance wrapping the produced value of type T
is returned. Otherwise, when the operation fails a Result
instance wrapping the error of type E
is returned.
Methods
If the result is a ResultOk
instance invokes the @handler
function, providing the wrapped value as the
argument and returns the result. Otherwise, returns the original ResultErr
instance.
If the result is a ResultOk
instance invokes the @handler.ok
function, providing the wrapped value as the
argument and returns the result.
Otherwise, invokes the @handler.err
function, providing the wrapped error as the argument and returns the result.
If the result is a ResultOk
instance invokes the @handler
function, providing the wrapped value as the
argument.
If the result is a ResultErr
instance invokes the @handler
function, providing the wrapped error as the
argument.
If the result is a ResultOk
instance returns the wrapped value. Otherwise, throws an Error
.
If the result is a ResultErr
instance returns the specified @def
value. Otherwise, returns the original
wrapped value.
If the result is a ResultErr
instance returns the wrapped error. Otherwise, throws an Error
.