{"id":28237256,"url":"https://github.com/just-do-halee/rusultts","last_synced_at":"2026-02-28T15:31:58.426Z","repository":{"id":43052381,"uuid":"413358889","full_name":"just-do-halee/rusultts","owner":"just-do-halee","description":"Rust Result Implementation for Typescript, simply. i.e. Modern error handling library.","archived":false,"fork":false,"pushed_at":"2021-10-06T11:50:41.000Z","size":89,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T05:20:56.011Z","etag":null,"topics":["debug","error","error-handling","exception","handling","library","modern","result","rust","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/just-do-halee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-04T09:36:26.000Z","updated_at":"2023-05-11T07:18:06.000Z","dependencies_parsed_at":"2022-07-09T08:30:36.060Z","dependency_job_id":null,"html_url":"https://github.com/just-do-halee/rusultts","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/just-do-halee/rusultts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Frusultts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Frusultts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Frusultts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Frusultts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/just-do-halee","download_url":"https://codeload.github.com/just-do-halee/rusultts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Frusultts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29940284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:49:17.081Z","status":"ssl_error","status_checked_at":"2026-02-28T13:48:50.396Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["debug","error","error-handling","exception","handling","library","modern","result","rust","typescript"],"created_at":"2025-05-19T00:17:55.377Z","updated_at":"2026-02-28T15:31:58.391Z","avatar_url":"https://github.com/just-do-halee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `rusultTs`\n\nRust **_Result Implementation for Typescript_**, simply. i.e. Modern error handling library. (no dependencies, pure Typescript code about 200 lines) 100% [[coverage]][ci-url]\n\u003cbr\u003e\n\u003cbr\u003e\n\n[![Coverage lines](./badges/badge-lines.svg)][ci-url]\n[![Coverage functions](./badges/badge-functions.svg)][ci-url]\n[![Coverage branches](./badges/badge-branches.svg)][ci-url]\n[![Coverage statements](./badges/badge-statements.svg)][ci-url]\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![CI](https://github.com/just-do-halee/rusultts/actions/workflows/main.yml/badge.svg)][ci-url]\n[![License][license-image]][license-url]\n[![run on repl.it](https://repl.it/badge/github/just-do-halee/rusultts)](https://replit.com/@justdohalee/rusultts-playground#index.ts)\n[[changelog]](CHANGELOG.md)\n\n---\n\n## **Installation**\u003cbr\u003e\n\n```js\nnpm install rusultts\n```\n\nor\n\n```js\nyarn add rusultts\n```\n\n## **Examples**\u003cbr\u003e\n\n```ts\nimport { Result, Ok, Err } from 'rusultts';\n\n// Result\u003cT\u003e: any type can be into it,\n// This is just the generic type.\n\n// I chose \u003cT\u003e as object.\n\ntype SomeType = { foo: string, bar: number };\n\n// Also these are just some example functions.\n\nfunction tryParse(token: string): Result\u003cSomeType\u003e {\n\n  // ... doing heavy stuffs ...\n\n  if (somethingWrong) { // happended\n\n    // so returns an Error-Object implementing Result\u003cT\u003e\n\n    return Err.new(`something wrong...`, null);\n\n  }\n\n  // Or returns an Ok Object containing value for \u003cSomeType\u003e\n\n  return Ok.new({ foo: 'any', bar: 999 });\n\n}\n\n// tryParse() wrapping function\n\nfunction verify(token: string): Result\u003cboolean\u003e {\n\n  // ↓ automatic throwing new Error(), or retuns the \u003cSomeType\u003e directly.\n\n  const someType = tryParse(token).unwrap();\n\n  // ... doing more stuffs ...\n\n  // another unwrap\n\n  const isItGood = tryGetBool(...).unwrap();\n\n  // ...\n\n  return Ok.new(isItGood);\n}\n\ntry {\n\n  // if unwrap is possible, you get a sign that you can use an obvious try catch statement.\n\n  const bool = verify(someToken).unwrap();\n\n} catch(e) {\n\n  // ↓ can get [`string`, 'E | null'] type value.\n\n  const [msg, value] = Err.eSplit(e);\n\n  // message of error \u0026 contained value\u003cE\u003e\n  // this value is `null` because of Result\u003cT\u003e = ResultBox\u003cT, null\u003e\n\n  console.log(msg, value);\n\n}\n```\n\n### ResultBox\n\n```ts\ntype Result\u003cT\u003e = ResultBox\u003cT, null\u003e;\n```\n\n```ts\nimport { ResultBox, Ok, Err } from 'rusultts';\n\n// simple example\n// ResultBox\u003cT, E\u003e: \u003cE\u003e equals containing user value for Error statement. it can be any type.\n\nfunction divide(a: number, b: number): ResultBox\u003cnumber, number\u003e {\n  if (b === 0) {\n    return Err.new(`b cannot be `, b);\n  }\n  return Ok.new(a / b);\n}\n\nconst val = divide(4, 2).unwrap(); // 4 / 2 = 2\nconst err = divide(4, 0); // 4 / 0, so error statement.\n\nconsole.log(err.isErr); // true\n\n// returns contained value\u003cnumber\u003e = 0\nconst getValueE = err.unwrap_err();\n\n// if state is error, returns input value = 10\nconst getDefault = err.unwrap_or(10);\n\n// like .map((x) =\u003e y) for value\u003cE\u003e\n// ↓ will return 1\nconst getMapped = err.unwrap_or_else((eV: number) =\u003e eV + 1);\n\ntry {\n  err.unwrap();\n} catch (e) {\n  const [errMessage, valueE] = Err.eSplit(e);\n\n  // print `b cannot be :--\u003e -1` out.\n  console.log(errMessage, (-1 + valueE) as number);\n}\n```\n\n## **Advanced**\u003cbr\u003e\n\n#### **./errors.ts**\n\n```ts\nimport { createErrorSet } from 'rusultts';\n\n// you can easily set all errors.\n\nexport default createErrorSet({\n  notFound: 'not found',\n  somethingWrong: 'something wrong...',\n  wrongHeader: 'please fix your header.',\n  undefinedValue: 'this value is undefined:',\n  dividedByZero: 'do not divide by Zero.',\n  dividedByNegative: 'well, you did divide as Negative value.',\n});\n```\n\n```ts\nimport { ResultBox, Ok, Err } from 'rusultts';\n\nimport err from './errors'; // import errors\n\nfunction divide(a: number, b: number): ResultBox\u003cnumber, number\u003e {\n  if (b === 0) {\n    return err.new('dividedByZero', b); // autocompleted string argument\n  } else if (b \u003c 0) {\n    return err.new('dividedByNegative', b);\n  }\n  return Ok.new(a / b);\n}\n\ntry {\n  divide(4, -2).unwrap(); // dividedByNegative error occurs.\n} catch (e) {\n  // you can do error type matching.\n  const val1 = err.match(e, 'dividedByZero').unwrap(); // this will return undefined.\n  const val2 = err.match(e, 'dividedByNegative').unwrap(); // this will return value of number type, `-2`\n  const val3 = err.match({ is: 'not errorType' }, 'dividedByNegative').unwrap(); // throw new Error\n}\n```\n\n## **License**\u003cbr\u003e\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/rusultts.svg\n[npm-url]: https://npmjs.org/package/rusultts\n[downloads-image]: https://img.shields.io/npm/dm/rusultts.svg\n[downloads-url]: https://npmcharts.com/compare/rusultts?minimal=true\n[license-url]: https://opensource.org/licenses/MIT\n[license-image]: https://img.shields.io/npm/l/rusultts\n[ci-url]: https://github.com/just-do-halee/rusultts/actions/workflows/main.yml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-do-halee%2Frusultts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjust-do-halee%2Frusultts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-do-halee%2Frusultts/lists"}