{"id":22741958,"url":"https://github.com/kyleect/rsresult","last_synced_at":"2025-03-30T04:14:32.496Z","repository":{"id":265511433,"uuid":"895698873","full_name":"kyleect/rsresult","owner":"kyleect","description":"A library to work with serde_json serialized `Result` objects","archived":false,"fork":false,"pushed_at":"2024-12-18T04:16:39.000Z","size":169,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T06:34:16.854Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://kyleect.github.io/rsresult/","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/kyleect.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":"2024-11-28T17:52:23.000Z","updated_at":"2024-12-18T04:12:53.000Z","dependencies_parsed_at":"2024-12-18T05:20:49.680Z","dependency_job_id":"0e590d1c-1e2d-497f-8dbf-a6630278f487","html_url":"https://github.com/kyleect/rsresult","commit_stats":null,"previous_names":["kyleect/rsresult"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleect%2Frsresult","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleect%2Frsresult/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleect%2Frsresult/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleect%2Frsresult/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyleect","download_url":"https://codeload.github.com/kyleect/rsresult/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246273552,"owners_count":20750906,"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":[],"created_at":"2024-12-11T00:22:10.178Z","updated_at":"2025-03-30T04:14:32.473Z","avatar_url":"https://github.com/kyleect.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rsresult\n\n[![ci](https://github.com/kyleect/rsresult/actions/workflows/ci.yml/badge.svg)](https://github.com/kyleect/rsresult/actions/workflows/ci.yml)\n\nA library to work with [serde_json](https://github.com/serde-rs/json) serialized `Result` objects. This library provides functions for creating, checking, and manipulating results, simplifying error handling in your JavaScript projects.\n\n[API Documentation](https://kyleect.github.io/rsresult/)\n\n## Installation\n\n![NPM Version](https://img.shields.io/npm/v/rsresult)\n\n```bash\nnpm install rsresult\n```\n\n## Usage\n\n```typescript\nimport assert from \"node:assert\";\nimport * as RsResult from \"rsresult\";\n\n// Successful Result\nconst success: RsResult.Ok\u003cnumber\u003e = RsResult.ok(123);\n\nassert(RsResult.isOk(success)); // passes\nassert(RsResult.isErr(success)); // fails\n\n// Map successful results\nconst mappedSuccess = RsResult.map(success, (value) =\u003e value * 2);\n\nassert(RsResult.unwrap(mappedSuccess) === 246);\n\ntry {\n  ResultRs.unwrapErr(success); // Throws an error\n} catch (error) {\n  assert(error instanceof Error);\n  assert(error.message.includes(\"Unwrapping an ok result: 123\"));\n}\n\n// Failed Result\nconst failed: RsResult.Err\u003cstring\u003e = RsResult.err(\"Error message\");\n\n// Map error results\nconst mappedError = RsResult.mapErr(failed, (value) =\u003e `Error: ${value}`);\nassert(RsResult.unwrap(mappedError) === \"Error: Error message\");\n\nassert(RsResult.isErr(failed)); // passes\nassert(RsResult.isOk(failed)); // fails\n\ntry {\n  RsResult.unwrap(failed); // Throws an error\n} catch (error) {\n  assert(error instanceof Error);\n  assert(error.message.includes(\"Unwrapping an error result: Error message\"));\n}\n\nassert(Results.unwrapErr(failed) === \"Error message\");\n\n//Example using ifOkOr\nRsResult.ifOk(success, (value) =\u003e console.log(\"Success:\", value));\n\nRsResult.ifOkOr(\n  failed,\n  (value) =\u003e console.log(\"Success:\", value),\n  (error) =\u003e console.error(\"Error:\", error)\n);\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleect%2Frsresult","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyleect%2Frsresult","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleect%2Frsresult/lists"}