Result44
Constructors
failconstCreates a Result holding a Failure value.failVoidconstProvides a pre-built failed Result whose failure value is undefined.fromNullishOrconstConverts a possibly null or undefined value into a Result.fromOptionconstConverts an Option<A> into a Result<A, E>.liftPredicateconstLifts a value into a Result based on a predicate or refinement.succeedconstCreates a Result holding a Success value.succeedNoneconstProvides a pre-built Result<Option<never>> that succeeds with None.succeedSomeconstCreates a Result<Option<A>> that succeeds with Some(a).Models
FailureinterfaceThe failure variant of Result.ResulttypeA value that is either Success<A, E> or Failure<A, E>.ResultUnifyinterfaceType-level utility for unifying Result types in generic contexts.ResultUnifyIgnoreinterfaceMarker interface for ignoring unification in Result types.SuccessinterfaceThe success variant of Result.Guards
Getters
getFailureconstExtracts the failure value as an Option, discarding the success.getOrElseconstExtracts the success value, or computes a fallback from the error.getOrNullconstExtracts the success value, or returns null on failure.getOrThrowconstExtracts the success value or throws the raw failure value E.getOrThrowWithconstExtracts the success value or throws a custom error derived from the failure.getOrUndefinedconstExtracts the success value, or returns undefined on failure.getSuccessconstExtracts the success value as an Option, discarding the failure.mergeconstUnwraps a Result into A | E by returning the inner value regardless of whether it is a success or failure.Mapping
mapconstTransforms the success channel of a Result, leaving the failure channel unchanged.mapBothconstTransforms both the success and failure channels of a Result.mapErrorconstTransforms the failure channel of a Result, leaving the success channel unchanged.tapconstRuns a side-effect on the success value without altering the Result.Filtering
Sequencing
Do Notation
bindconstAdds a named field to the do-notation accumulator by running a Result-producing function that receives the current accumulated object.bindToconstWraps the success value of a Result into a named field, producing a Result<Record<N, A>>.DoconstProvides the starting point for the "do notation" simulation with Result.