{"id":27208025,"url":"https://github.com/hsequeda/fpts-monads","last_synced_at":"2026-05-09T15:05:25.655Z","repository":{"id":57241252,"uuid":"367947244","full_name":"hsequeda/fpts-monads","owner":"hsequeda","description":"An implementation of the Result and the Optional FP monad in Typescript. This library was inspired by the handling of these monads in the standard Rust library. Asynchronous functions can be chained.","archived":false,"fork":false,"pushed_at":"2022-02-02T20:11:16.000Z","size":121,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T23:59:02.220Z","etag":null,"topics":["fp","javascript","monad","result-type","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hsequeda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-16T17:38:27.000Z","updated_at":"2024-11-15T22:09:08.000Z","dependencies_parsed_at":"2022-09-08T00:40:50.684Z","dependency_job_id":null,"html_url":"https://github.com/hsequeda/fpts-monads","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsequeda%2Ffpts-monads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsequeda%2Ffpts-monads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsequeda%2Ffpts-monads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsequeda%2Ffpts-monads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hsequeda","download_url":"https://codeload.github.com/hsequeda/fpts-monads/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131331,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fp","javascript","monad","result-type","typescript"],"created_at":"2025-04-09T23:59:05.074Z","updated_at":"2026-05-09T15:05:25.566Z","avatar_url":"https://github.com/hsequeda.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fpts-monads\n\nAn implementation of the Result and the Optional FP monad in Typescript. This\nlibrary was inspired by the handling of these monads in the standard Rust library.\nAsynchronous functions can be chained.\n\n## Example\n\nSee the example folder in `src/example`.\n\n### Optional Example\n\n```typescript\nfunction optionalExample(req?: string): string {\n  const reqOrNone = Optional(req);\n  return reqOrNone.match(\n    (reqVal: string) =\u003e {\n      return `Request value is: ${reqVal}`;\n    },\n    () =\u003e {\n      return `Request value is: None`;\n    }\n  );\n}\n```\n\n### Result Example\n\n```typescript\nclass SimpleError {\n  public name: string;\n  public message: string;\n  constructor(message: string) {\n    name: `SimpleError`;\n    this.message = message;\n  }\n\n  public pretty(): string {\n    return `[${this.name}] ${this.message}`;\n  }\n  public throw(): void {\n    throw new Error(this.pretty());\n  }\n}\n\nfunction resultExample(req?: string): Result\u003cstring\u003e {\n  const reqOrNone = Optional(req);\n  const reqOrErr = reqOrNone.okOr(new SimpleError(`Request doesn't exist`));\n  return reqOrErr;\n}\n\nfunction resultExample2(req?: string): Result\u003cstring\u003e {\n  try {\n    if (Optional(req).isNone()) throw new Error('Some error!');\n    return Result.Ok(req);\n  } catch (error) {\n    return Result.Fail(new SimpleError(`Request doesn't exist`));\n  }\n}\n```\n\n## WIP\n\nImplement a proxy to chain `async` functions without add async declaration in each\nsentence.\n\n## Optional methods\n\n```typescript\n  /*\n   * Returns true if the option is a None value.\n   *\n   * @returns  {boolean}\n   * @memberof Optional\n   */\n  isNone(): boolean;\n\n  /**\n   * Returns true if the option is a Some value.\n   *\n   * @returns  {boolean}\n   * @memberof Optional\n   */\n  isSome(): boolean;\n\n  /**\n   * Returns the contained 'Some' value, if is 'None' throw an error with the\n   * passed message.\n   *\n   * @param {string} msg\n   * @returns  {A}\n   * @memberof Optional\n   */\n  expect(msg: string): A;\n\n  /**\n   * Returns the contained 'Some' value, if is 'None' throw an error.\n   *\n   * @returns  {A}\n   * @memberof Optional\n   */\n  unwrap(): A;\n\n  /**\n   * Returns the contained 'Some' value or a provided default. Arguments passed\n   * to unwrapOr are eagerly evaluated; if you are passing the result of a\n   * function call, it is recommended to use unwrapOrElse, which is lazily evaluated.\n   *\n   * @param {A} def\n   * @returns  {A}\n   * @memberof Optional\n   */\n  unwrapOr(def: A): A;\n\n  /**\n   * Returns the contained 'Some' value or computes it from a closure.\n   *\n   * @param {(() =\u003e A)} func\n   * @returns  {(A)}\n   * @memberof Optional\n   */\n  unwrapOrElse(func: () =\u003e A): A;\n\n  /**\n   * Returns the contained 'Some' value or computes it from a closure.\n   *\n   * @param {(() =\u003e Promise\u003cA\u003e)} func\n   * @returns  {(Promise\u003cA\u003e)}\n   * @memberof Optional\n   */\n  unwrapOrElseAsync(func: () =\u003e Promise\u003cA\u003e): Promise\u003cA\u003e;\n\n  /**\n   * Maps an Option\u003cT\u003e to Option\u003cU\u003e by applying a function to a contained value.\n   *\n   * @template B\n   * @param {(a: A) =\u003e B} func\n   * @returns  {Optional\u003cB\u003e}\n   * @memberof Optional\n   */\n  map\u003cB\u003e(func: (a: A) =\u003e B): Optional\u003cB\u003e;\n\n  /**\n   * Maps an Option\u003cT\u003e to Option\u003cU\u003e by applying a function to a contained value.\n   *\n   * @template B\n   * @param {(a: A) =\u003e Promise\u003cB\u003e} func\n   * @returns  {Promise\u003cOptional\u003cB\u003e\u003e}\n   * @memberof Optional\n   */\n  mapAsync\u003cB\u003e(func: (a: A) =\u003e Promise\u003cB\u003e): Promise\u003cOptional\u003cB\u003e\u003e;\n\n  /**\n   * Applies a function to the contained value (if any), or returns the provided\n   * default (if not).  Arguments passed to mapOr are eagerly evaluated; if you\n   * are passing the result of a function call, it is recommended to use\n   * mapOrElse, which is lazily evaluated.\n   *\n   * @template B\n   * @param {B} def\n   * @param {(a: A) =\u003e B} func\n   * @returns  {B}\n   * @memberof Optional\n   */\n  mapOr\u003cB\u003e(def: B, func: (a: A) =\u003e B): B;\n\n  /**\n   * Applies a function to the contained value (if any), or returns the provided\n   * default (if not).  Arguments passed to mapOr are eagerly evaluated; if you\n   * are passing the result of a function call, it is recommended to use\n   * mapOrElse, which is lazily evaluated.\n   *\n   * @template B\n   * @param {B} def\n   * @param {(a: A) =\u003e Promise\u003cB\u003e} func\n   * @returns  {Promise\u003cB\u003e}\n   * @memberof Optional\n   */\n  mapOrAsync\u003cB\u003e(def: B, func: (a: A) =\u003e Promise\u003cB\u003e): Promise\u003cB\u003e;\n\n  /**\n   * Applies a function to the contained value (if any), or computes a default\n   * (if not).\n   *\n   * @template B\n   * @param {() =\u003e B} def\n   * @param {(a: A) =\u003e B} func\n   * @returns  {B}\n   * @memberof Optional\n   */\n  mapOrElse\u003cB\u003e(def: () =\u003e B, func: (a: A) =\u003e B): B;\n\n  /**\n   * Applies a function to the contained value (if any), or computes a default\n   * (if not).\n   *\n   * @template B\n   * @param {() =\u003e Promise\u003cB\u003e} def\n   * @param {(a: A) =\u003e Promise\u003cB\u003e} func\n   * @returns  {Promise\u003cB\u003e}\n   * @memberof Optional\n   */\n  mapOrElseAsync\u003cB\u003e(\n    def: () =\u003e Promise\u003cB\u003e,\n    func: (a: A) =\u003e Promise\u003cB\u003e\n  ): Promise\u003cB\u003e;\n\n  /**\n   * Transforms the Option\u003cT\u003e into a Result\u003cT, E\u003e, mapping 'Some(v)' to 'Ok(v)'\n   * and 'None' to 'Error(err)'.  Arguments passed to okOr are eagerly\n   * evaluated; if you are passing the result of a function call, it is\n   * recommended to use okOrElse, which is lazily evaluated.\n   *\n   * @template E\n   * @param {E} err\n   * @returns  {Result\u003cA\u003e}\n   * @memberof Optional\n   */\n  okOr\u003cE extends IResultError\u003e(err: E): Result\u003cA\u003e;\n\n  /**\n   * Transforms the Option\u003cT\u003e into a Result\u003cT, E\u003e, mapping 'Some(v)' to 'Ok(v)'\n   * and 'None' to 'Err(func())'.\n   *\n   * @template E\n   * @param {() =\u003e E} errFunc\n   * @returns  {Result\u003cA\u003e}\n   * @memberof Optional\n   */\n  okOrElse\u003cE extends IResultError\u003e(errFunc: () =\u003e E): Result\u003cA\u003e;\n\n  /**\n   * Transforms the Option\u003cT\u003e into a Result\u003cT, E\u003e, mapping 'Some(v)' to 'Ok(v)'\n   * and 'None' to 'Err(func())'.\n   *\n   * @template E\n   * @param {() =\u003e Promise\u003cE\u003e} errFunc\n   * @returns  {Promise\u003cResult\u003cA\u003e\u003e}\n   * @memberof Optional\n   */\n  okOrElseAsync\u003cE extends IResultError\u003e(\n    errFunc: () =\u003e Promise\u003cE\u003e\n  ): Promise\u003cResult\u003cA\u003e\u003e;\n\n  /**\n   * Applies the 'some' function if is 'Some(v)' and the 'none' function if is 'None'.\n   *\n   * @template S\n   * @param {(a: A) =\u003e S} some\n   * @param {() =\u003e S} none\n   * @returns  {S}\n   * @memberof Optional\n   */\n  match\u003cS\u003e(some: (a: A) =\u003e S, none: () =\u003e S): S;\n\n  /**\n   * Applies the 'some' function if is 'Some(v)' and the 'none' function if is 'None'.\n   *\n   * @template S\n   * @param {(a: A) =\u003e Promise\u003cS\u003e} some\n   * @param {() =\u003e Promise\u003cS\u003e} none\n   * @returns  {Promise\u003cS\u003e}\n   * @memberof Optional\n   */\n  matchAsync\u003cS\u003e(some: (a: A) =\u003e Promise\u003cS\u003e, none: () =\u003e Promise\u003cS\u003e): Promise\u003cS\u003e;\n\n  /**\n   * Returns 'None' if the option is 'None', otherwise returns 'optb'.\n   *\n   * @template U\n   * @param {Optional\u003cU\u003e} optb\n   * @returns  {Optional\u003cU\u003e}\n   * @memberof Optional\n   */\n  and\u003cU\u003e(optb: Optional\u003cU\u003e): Optional\u003cU\u003e;\n\n  /**\n   * Returns 'None' if the option is 'None', otherwise calls 'func' with the \n   * wrapped value and returns the result. Some languages call this operation flatmap.\n   *\n   * @template U\n   * @param {((val: A) =\u003e Optional\u003cU\u003e | Promise\u003cOptional\u003cU\u003e\u003e)} func\n   * @returns  {(Optional\u003cU\u003e | Promise\u003cOptional\u003cU\u003e\u003e)}\n   * @memberof Optional\n   */\n  andThen\u003cU\u003e(\n    func: (val: A) =\u003e Optional\u003cU\u003e | Promise\u003cOptional\u003cU\u003e\u003e\n  ): Optional\u003cU\u003e | Promise\u003cOptional\u003cU\u003e\u003e;\n\n  /**\n   * Returns 'None' if the option is 'None', otherwise calls 'func' with the\n   * wrapped value and returns the result. Some languages call this operation flatmap.\n   *\n   * @template U\n   * @param {(val: A) =\u003e Promise\u003cOptional\u003cU\u003e\u003e} func\n   * @returns  {Promise\u003cOptional\u003cU\u003e\u003e}\n   * @memberof Optional\n   */\n  andThenAsync\u003cU\u003e(func: (val: A) =\u003e Promise\u003cOptional\u003cU\u003e\u003e): Promise\u003cOptional\u003cU\u003e\u003e;\n\n  /**\n   * Returns the option if it contains a value, otherwise returns 'optb'. \n   * Arguments passed to or are eagerly evaluated; if you are passing the result\n   * of a function call, it is recommended\n   * to use orElse, which is lazily evaluated.\n   *\n   * @param {Optional\u003cA\u003e} optb\n   * @returns  {Optional\u003cA\u003e}\n   * @memberof Optional\n   */\n  or(optb: Optional\u003cA\u003e): Optional\u003cA\u003e;\n\n  /**\n   * Returns the option if it contains a value, otherwise calls 'func' and \n   * returns the result.\n   *\n   * @param {() =\u003e Optional\u003cA\u003e} func\n   * @returns  {Optional\u003cA\u003e}\n   * @memberof Optional\n   */\n  orElse(func: () =\u003e Optional\u003cA\u003e): Optional\u003cA\u003e;\n\n  /**\n   * Returns the option if it contains a value, otherwise calls 'func' and \n   * returns the result.\n   *\n   * @param {() =\u003e Promise\u003cOptional\u003cA\u003e\u003e} func\n   * @returns  {Promise\u003cOptional\u003cA\u003e\u003e}\n   * @memberof Optional\n   */\n  orElseAsync(func: () =\u003e Promise\u003cOptional\u003cA\u003e\u003e): Promise\u003cOptional\u003cA\u003e\u003e;\n\n  /**\n   * Returns 'Some' if exactly one of 'this', 'optb' is 'Some', otherwise returns\n   * 'None'.\n   *\n   * @param {Optional\u003cA\u003e} optb\n   * @returns  {Optional\u003cA\u003e}\n   * @memberof Optional\n   */\n  xor(optb: Optional\u003cA\u003e): Optional\u003cA\u003e;\n```\n\n## Result methods\n\n``` typescript\n  /**\n   * Converts from Result\u003cR, E\u003e to Optional\u003cR\u003e.\n   *\n   * @returns  {Optional\u003cR\u003e}\n   * @memberof Result\n   */\n  public getValue(): Optional\u003cR\u003e;\n\n  public errorValue(): Optional\u003cE\u003e; \n\n  /**\n   * Maps a Result\u003cR, E\u003e to Result\u003cT, E\u003e by applying a function to a contained \n   * 'OK' value, leaving an 'Error' value untouched. This function can be used \n   * to compose the results of two functions.\n   *\n   * @template T\n   * @param {(a: R) =\u003e T} func\n   * @returns  {Result\u003cT\u003e}\n   * @memberof Result\n   */\n  public map\u003cT\u003e(func: (a: R) =\u003e T): Result\u003cT\u003e;\n\n  /**\n   * Maps a Result\u003cR, E\u003e to Result\u003cT, E\u003e by applying a function to a contained \n   * 'OK' value, leaving an 'Error' value untouched. This function can be used \n   * to compose the results of two functions.\n   *\n   * @template T\n   * @param {(a: R) =\u003e Promise\u003cT\u003e} func\n   * @returns  {Promise\u003cResult\u003cT\u003e\u003e}\n   * @memberof Result\n   */\n  public async mapAsync\u003cT\u003e(func: (a: R) =\u003e Promise\u003cT\u003e): Promise\u003cResult\u003cT\u003e\u003e;\n\n  /**\n   * Applies a function to the contained value (if Ok), or returns the provided \n   * default (if Error).\n   * Arguments passed to mapOr are eagerly evaluated; if you are passing the \n   * result of a function call,\n   * it is recommended to use mapOrElse, which is lazily evaluated.\n   *\n   * @template T\n   * @param {T} def\n   * @param {(a: R) =\u003e T} func\n   * @returns  {T}\n   * @memberof Result\n   */\n  public mapOr\u003cT\u003e(def: T, func: (a: R) =\u003e T): T;\n\n  /**\n   * Applies a function to the contained value (if Ok), or returns the provided \n   * default (if Error).\n   * Arguments passed to mapOr are eagerly evaluated; if you are passing the \n   *  result of a function call,\n   * it is recommended to use mapOrElse, which is lazily evaluated.\n   *\n   * @template T\n   * @param {T} def\n   * @param {(a: R) =\u003e Promise\u003cT\u003e} func\n   * @returns  {Promise\u003cT\u003e}\n   * @memberof Result\n   */\n  public async mapOrAsync\u003cT\u003e(\n    def: T,\n    func: (a: R) =\u003e T | Promise\u003cT\u003e\n  ): Promise\u003cT\u003e;\n\n  /**\n   * Maps a Result\u003cR, E\u003e to T by applying a function to a contained 'Ok' value, \n   * or a fallback function to\n   * a contained 'Error' value. This function can be used to unpack a successful\n   * result while handling an error.\n   *\n   * @template T\n   * @param {(a: E) =\u003e Promise\u003cT\u003e} def\n   * @param {(a: R) =\u003e Promise\u003cT\u003e} func\n   * @returns  {Promise\u003cT\u003e}\n   * @memberof Result\n   */\n  public async mapOrElseAsync\u003cT\u003e(\n    def: (a: E) =\u003e Promise\u003cT\u003e,\n    func: (a: R) =\u003e Promise\u003cT\u003e\n  ): Promise\u003cT\u003e;\n\n  /**\n   * Maps a Result\u003cR, E\u003e to T by applying a function to a contained 'Ok' value, \n   * or a fallback function to\n   * a contained 'Error' value. This function can be used to unpack a successful\n   * result while handling an error.\n   *\n   * @template T\n   * @param {(a: E) =\u003e T} def\n   * @param {(a: R) =\u003e T} func\n   * @returns  {T}\n   * @memberof Result\n   */\n  public mapOrElse\u003cT\u003e(def: (a: E) =\u003e T, func: (a: R) =\u003e T): T;\n\n  /**\n   * Maps a Result\u003cR, E\u003e to Result\u003cR, F\u003e by applying a function to a contained\n   * 'Error' value,\n   * leaving an 'Ok' value untouched. This function can be used to pass through\n   * a successful result while handling an error.\n   *\n   * @template F\n   * @param {(a: E) =\u003e Promise\u003cF\u003e} func\n   * @returns  {Promise\u003cResult\u003cR, F\u003e\u003e}\n   * @memberof Result\n   */\n  public async mapOrErrorAsync\u003cF extends IResultError = IResultError\u003e(\n    func: (a: E) =\u003e Promise\u003cF\u003e\n  ): Promise\u003cResult\u003cR, F\u003e\u003e; \n\n  /**\n   * Maps a Result\u003cR, E\u003e to Result\u003cR, F\u003e by applying a function to a contained \n   * 'Error' value, leaving an 'Ok' value untouched. This function can be used \n   * to pass through a successful result while handling an error.\n   *\n   * @template F\n   * @param {(a: E) =\u003e F} func\n   * @returns  {Result\u003cR, F\u003e}\n   * @memberof Result\n   */\n  public mapOrError\u003cF extends IResultError = IResultError\u003e(\n    func: (a: E) =\u003e F\n  ): Result\u003cR, F\u003e;\n\n  /**\n   * Returns res if the result is 'Ok', otherwise returns the Err value of 'this'.\n   *\n   * @template U\n   * @param {Result\u003cU, E\u003e} res\n   * @returns  {Result\u003cU, E\u003e}\n   * @memberof Result\n   */\n  public and\u003cU\u003e(res: Result\u003cU, E\u003e): Result\u003cU, E\u003e;\n\n  /**\n   * Calls 'func' if the result is 'Ok', otherwise returns the 'Error' value of 'this'.\n   * This function can be used for control flow based on Result values.\n   *\n   * @template U\n   * @param {((val: R) =\u003e Promise\u003cResult\u003cU, E\u003e\u003e)} func\n   * @returns  {Promise\u003cResult\u003cU, E\u003e\u003e}\n   * @memberof Result\n   */\n  public async andThenAsync\u003cU\u003e(\n    func: (val: R) =\u003e Promise\u003cResult\u003cU, E\u003e\u003e\n  ): Promise\u003cResult\u003cU, E\u003e\u003e;\n\n  /**\n   * Calls 'func' if the result is 'Ok', otherwise returns the 'Error' value of 'this'.\n   * This function can be used for control flow based on Result values.\n   *\n   * @template U\n   * @param {(val: R) =\u003e Result\u003cU, E\u003e} func\n   * @returns  {Result\u003cU, E\u003e}\n   * @memberof Result\n   */\n  public andThen\u003cU\u003e(func: (val: R) =\u003e Result\u003cU, E\u003e): Result\u003cU, E\u003e;\n\n  /**\n   * Returns 'res' if the result is 'Error', otherwise returns the 'Ok' value of\n   * 'this'.  Arguments passed to 'or' are eagerly evaluated; if you are passing\n   * the result of a function call, it is recommended to use orElse, which is \n   * lazily evaluated.\n   *\n   * @template F\n   * @param {Result\u003cR, F\u003e} res\n   * @returns  {Result\u003cR, F\u003e}\n   * @memberof Result\n   */\n  public or\u003cF extends IResultError = IResultError\u003e(\n    res: Result\u003cR, F\u003e\n  ): Result\u003cR, F\u003e; \n\n  /**\n   * Calls 'func' if the result is 'Error', otherwise returns the 'Ok' value of 'this'.\n   * This function can be used for control flow based on result values.\n   *\n   * @template F\n   * @param {(err: E) =\u003e Promise\u003cResult\u003cR, F\u003e\u003e} func\n   * @returns  {Promise\u003cResult\u003cR, F\u003e\u003e}\n   * @memberof Result\n   */\n  public async orElseAsync\u003cF extends IResultError = IResultError\u003e(\n    func: (err: E) =\u003e Promise\u003cResult\u003cR, F\u003e\u003e\n  ): Promise\u003cResult\u003cR, F\u003e\u003e;\n\n  /**\n   * Calls 'func' if the result is 'Error', otherwise returns the 'Ok' value of 'this'.\n   * This function can be used for control flow based on result values.\n   *\n   * @template F\n   * @param {(err: E) =\u003e Result\u003cR, F\u003e} func\n   * @returns  {Result\u003cR, F\u003e}\n   * @memberof Result\n   */\n  public orElse\u003cF extends IResultError = IResultError\u003e(\n    func: (err: E) =\u003e Result\u003cR, F\u003e\n  ): Result\u003cR, F\u003e;\n\n  /**\n   * Returns the contained 'Ok' value. If the value is an 'Error' then throw an error\n   * including the passed message.\n   *\n   * @param {string} msg\n   * @returns  {R}\n   * @memberof Result\n   */\n  public expect(msg: string): R;\n\n  /**\n   * Returns the contained 'Ok' value. If the value is an 'Error' then throw it.\n   *\n   * @returns  {R}\n   * @memberof Result\n   */\n  public unwrap(): R;\n\n  /**\n   * Returns the contained 'Ok' value or a provided default. Arguments passed to\n   * unwrapOr are eagerly evaluated; if you are passing the result of a \n   * function call, it is recommended to use unwrapOrElse, which is lazily evaluated.\n   *\n   * @param {R} def\n   * @returns  {R}\n   * @memberof Result\n   */\n  public unwrapOr(def: R): R;\n\n  /**\n   * Returns the contained 'Ok' value or computes it from a closure.\n   *\n   * @param {(err: E) =\u003e Promise\u003cR\u003e} func\n   * @returns  {Promise\u003cR\u003e}\n   * @memberof Result\n   */\n  public async unwrapOrElseAsync(func: (err: E) =\u003e R | Promise\u003cR\u003e): Promise\u003cR\u003e;\n\n  /**\n   * Returns the contained 'Ok' value or computes it from a closure.\n   *\n   * @param {(err: E) =\u003e R} func\n   * @returns  {R}\n   * @memberof Result\n   */\n  public unwrapOrElse(func: (err: E) =\u003e R): R;\n\n  /**\n   * Returns the contained 'Err' value, consuming the 'this' value.\n   *\n   * @returns  {E}\n   * @memberof Result\n   */\n  public unwrapError(): E;\n\n  /**\n   * Create a success Result value. IsSuccess returns true.\n   *\n   * @static\n   * @template U\n   * @template E\n   * @param {U} [value]\n   * @returns  {Result\u003cU, E\u003e}\n   * @memberof Result\n   */\n  public static Ok\u003cU, E extends IResultError = IResultError\u003e(\n    value?: U\n  ): Result\u003cU, E\u003e;\n\n  /**\n   * Create a failure Result value. IsFailure returns true.\n   *\n   * @static\n   * @template U\n   * @template E\n   * @param {E} error\n   * @returns  {Result\u003cU, E\u003e}\n   * @memberof Result\n   */\n  public static Fail\u003cU, E extends IResultError = IResultError\u003e(\n    error: E\n  ): Result\u003cU, E\u003e;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsequeda%2Ffpts-monads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhsequeda%2Ffpts-monads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsequeda%2Ffpts-monads/lists"}