Skip to content

result

Builds a neutral Right result: neither positive nor negative, just a contextualized result with business information and an optional payload.

Interactive example

Syntax

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: Optional payload associated with this result.

Return value

A Result<Information, Value>, which is a specialized Right tagged with the additional result kind.

See also

  • right – Generic Right constructor with business information.
  • success – Shortcut for explicitly positive outcomes.
  • unwrapRightOrThrow – Unwraps a Right payload immediately.

Released under the MIT license.