result
Builds a neutral Right result: neither positive nor negative, just a contextualized result with business information and a payload.
Interactive example
Syntax
Classic
typescript
function result<
GenericInformation extends string,
const GenericValue extends unknown = undefined
>(
information: GenericInformation,
value: GenericValue
): Result<GenericInformation, GenericValue>Curried
typescript
function result<
GenericInformation extends string,
const GenericValue extends unknown = undefined
>(
information: GenericInformation
): (value: GenericValue) => Result<GenericInformation, GenericValue>Parameters
information: Literal string that describes the produced result ("invoice.total","user.skipped", etc.).value: Payload associated with this result. Passundefinedexplicitly when the result has no payload.
Return value
A Result<Information, Value>, which is a specialized Right tagged with the additional result kind.
When only information is provided, result returns a function waiting for value, which is useful in pipe.
See also
right– GenericRightconstructor with business information.success– Shortcut for explicitly positive outcomes.unwrapRightOrThrow– Unwraps aRightpayload immediately.
