{"id":18700236,"url":"https://github.com/olian04/simply-result","last_synced_at":"2026-05-01T06:33:57.205Z","repository":{"id":188462160,"uuid":"678744151","full_name":"Olian04/simply-result","owner":"Olian04","description":"Simply typesafe Result and Option monads in typescript and javascript.","archived":false,"fork":false,"pushed_at":"2024-02-22T17:00:52.000Z","size":169,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T03:30:44.026Z","etag":null,"topics":["fp","functional-programming","javascript","monad","monad-types","monads","option","option-type","result","result-type","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/simply-result","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/Olian04.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-15T09:15:14.000Z","updated_at":"2025-07-13T14:09:59.000Z","dependencies_parsed_at":"2023-09-22T09:43:47.999Z","dependency_job_id":"f23134c3-8e7f-49a7-a16d-208a2b2b0638","html_url":"https://github.com/Olian04/simply-result","commit_stats":null,"previous_names":["olian04/simply-result"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Olian04/simply-result","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olian04%2Fsimply-result","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olian04%2Fsimply-result/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olian04%2Fsimply-result/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olian04%2Fsimply-result/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Olian04","download_url":"https://codeload.github.com/Olian04/simply-result/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olian04%2Fsimply-result/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32487558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","functional-programming","javascript","monad","monad-types","monads","option","option-type","result","result-type","typescript"],"created_at":"2024-11-07T11:36:27.784Z","updated_at":"2026-05-01T06:33:57.180Z","avatar_url":"https://github.com/Olian04.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest released version](https://img.shields.io/npm/v/simply-result)](https://www.npmjs.com/package/simply-result)\n![Minified and gzipped bundle size](./assets/size.badge.svg)\n![Type support](https://img.shields.io/npm/types/simply-result)\n[![CI status](https://img.shields.io/github/actions/workflow/status/olian04/simply-result/ci.yml?event=push\u0026label=tests)](https://github.com/Olian04/simply-result/actions/workflows/ci.yml)\n[![Code coverage](https://img.shields.io/codecov/c/gh/olian04/simply-result?token=54HYINU8yj\u0026label=test%20coverage)](https://codecov.io/gh/Olian04/simply-result)\n[![Downloads from NPM](https://img.shields.io/npm/dm/simply-result?label=downloads%20npm)](https://www.npmjs.com/package/simply-result)\n[![MIT licensed](https://img.shields.io/npm/l/simply-result)](./LICENSE)\n\n# simply-result\n\nSimply result is a Result and Option monad library for typescript and javascript. Its more than [100 times faster than try-catch](#performance) with a total package size of ~700b minified and gzipped.\n\nSee also the sister library [simply-result-util](https://github.com/Olian04/simply-result-util) for useful monadic helper functions such as `Try`, `transpose`, and `flatten`.\n\n```ts\nimport { Result, Ok } from 'simply-result';\n\nconst doSomeWork = (): Result\u003cnumber, Error\u003e =\u003e Ok(3);\n\nconst fraction = doSomeWork()\n  .mapErr(err =\u003e console.error(err))\n  .intoOption()\n  .filter(it =\u003e it !== 0)\n  .map(it =\u003e (1 / it).toPrecision(3))\n  .unwrapOr('0');\n\nconsole.log(fraction); // '0.333'\n```\n\n## Installation\n\n### NPM\n\n[`npm i simply-result`](https://www.npmjs.com/package/simply-result)\n\n```ts\nimport {\n    Result, Ok, Err,\n    Option, Some, None,\n} from 'simply-result';\n```\n\n## Demo\n\n[See `./demo`](./demo/)\n\n## Type Docs\n\n### Result\n\n```ts\ntype Result\u003cV, E = Error\u003e =\n  | Ok\u003cV\u003e\n  | Err\u003cE\u003e\n\ninterface Ok\u003cV\u003e {\n  isOk: true\n  isErr: false\n  ok: V\n  match\u003cT\u003e(cases: {\n    Ok: (ok: V) =\u003e T\n  }): T\n  intoOption(): Some\u003cV\u003e\n  intoErrOption(): None\n  map\u003cT\u003e(fn: (ok: V) =\u003e T): Ok\u003cT\u003e\n  mapErr(fn: unknown): Ok\u003cV\u003e\n  andThen\u003cT\u003e(fn: (ok: V) =\u003e T): T\n  elseThen(fn: unknown): Ok\u003cV\u003e\n  unwrapOr(ok: unknown): V\n  unwrapElse(fn: unknown): V\n  toString(): string\n}\n\ninterface Err\u003cE\u003e {\n  isOk: false\n  isErr: true\n  err: E\n  match\u003cT\u003e(cases: {\n    Err: (err: E) =\u003e T\n  }): T\n  intoOption(): None\n  intoErrOption(): Some\u003cE\u003e\n  map(fn: unknown): Err\u003cE\u003e\n  mapErr\u003cF\u003e(fn: (err: E) =\u003e F): Err\u003cF\u003e\n  andThen(fn: unknown): Err\u003cE\u003e\n  elseThen\u003cT\u003e(fn: (err: E) =\u003e T): T\n  unwrapOr\u003cT\u003e(ok: T): T\n  unwrapElse\u003cT\u003e(fn: () =\u003e T): T\n  toString(): string\n}\n\nfunction Ok\u003cV\u003e(value: V): Ok\u003cV\u003e\n\nfunction Err\u003cE\u003e(error: E): Err\u003cE\u003e\n```\n\n### Option\n\n```ts\ntype Option\u003cV\u003e =\n  | Some\u003cV\u003e\n  | None\n\ninterface Some\u003cV\u003e {\n  isSome: true\n  isNone: false\n  some: V\n  match\u003cT\u003e(cases: {\n    Some: (some: V) =\u003e T\n  }): T\n  intoResult(error: unknown): Ok\u003cV\u003e\n  map\u003cT\u003e(fn: (some: V) =\u003e T): Some\u003cT\u003e\n  filter(fn: (some: V) =\u003e boolean): Option\u003cV\u003e\n  andThen\u003cT\u003e(fn: (some: V) =\u003e T): T\n  elseThen(fn: unknown): Some\u003cV\u003e\n  unwrapOr(some: unknown): V\n  unwrapElse(fn: unknown): V\n  toString(): string\n}\n\ninterface None {\n  isSome: false\n  isNone: true\n  match\u003cT\u003e(cases: {\n    None: () =\u003e T\n  }): T\n  intoResult\u003cE\u003e(error: E): Err\u003cE\u003e\n  map(fn: unknown): None\n  filter(fn: unknown): None\n  andThen(fn: unknown): None\n  elseThen\u003cT\u003e(fn: () =\u003e T): T\n  unwrapOr\u003cT\u003e(some: T): T\n  unwrapElse\u003cT\u003e(fn: () =\u003e T): T\n  toString(): string\n}\n\nfunction Some\u003cV\u003e(value: V): Some\u003cV\u003e\n\nconst None: None\n```\n\n## Performance\n\n|           | Code                                                    | Result                                            |\n|:---------:|:-------------------------------------------------------:|:-------------------------------------------------:|\n| Result    | `Err(new Error()).elseThen(err =\u003e { err.message })`     | `123,901,767 ops/sec ±0.15% (100 runs sampled)`   |\n| Try Catch | `try { throw new Error() } catch (err) { err.message }` | `1,125,735 ops/sec ±0.29% (67  runs sampled)`     |\n| Baseline  | `new Error().message`                                   | `1,027,606,577 ops/sec ±0.10% (101 runs sampled)` |\n\nAll performance tests use the same `Error` object which is created before testing as to minimize the impact of creating an error object on the measurements.\nTests were ran on a `32gb MacBook M1 Pro` running `macOS 14.3`. The test code can be found [here](./demo/perf.ts).\n\n```log\n(1/5) baseline  x 1,026,512,662 ops/sec ±0.13% (102 runs sampled)\n(2/5) baseline  x 1,025,374,916 ops/sec ±0.46% (94  runs sampled)\n(3/5) baseline  x 1,027,606,577 ops/sec ±0.10% (101 runs sampled)\n(4/5) baseline  x 1,027,408,614 ops/sec ±0.11% (100 runs sampled)\n(5/5) baseline  x 1,027,220,720 ops/sec ±0.15% (101 runs sampled)\n(1/5) Result    x   123,762,745 ops/sec ±0.21% (101 runs sampled)\n(2/5) Result    x   123,725,903 ops/sec ±0.20% (100 runs sampled)\n(3/5) Result    x   123,690,424 ops/sec ±0.21% (99  runs sampled)\n(4/5) Result    x   123,901,767 ops/sec ±0.15% (100 runs sampled)\n(5/5) Result    x   123,781,206 ops/sec ±0.25% (100 runs sampled)\n(1/5) try catch x     1,108,408 ops/sec ±0.34% (59  runs sampled)\n(2/5) try catch x     1,122,301 ops/sec ±0.37% (66  runs sampled)\n(3/5) try catch x     1,124,218 ops/sec ±0.37% (67  runs sampled)\n(4/5) try catch x     1,125,735 ops/sec ±0.29% (67  runs sampled)\n(5/5) try catch x     1,116,800 ops/sec ±0.39% (67  runs sampled)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folian04%2Fsimply-result","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folian04%2Fsimply-result","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folian04%2Fsimply-result/lists"}