{"id":25445499,"url":"https://github.com/arnavk-09/unwrap-go","last_synced_at":"2026-02-19T19:03:27.632Z","repository":{"id":276277583,"uuid":"928750598","full_name":"ArnavK-09/unwrap-go","owner":"ArnavK-09","description":"🫧 Go-like Error Handling for TypeScript/JavaScript...","archived":false,"fork":false,"pushed_at":"2025-02-08T20:42:13.000Z","size":118,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T06:59:42.882Z","etag":null,"topics":["bun","cross","error","handler","jsr","lib","node","npm","package","pkg","typescript","workflows"],"latest_commit_sha":null,"homepage":"https://jsr.io/@arnavk-09/unwrap-go/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArnavK-09.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":"2025-02-07T07:04:29.000Z","updated_at":"2025-02-08T20:42:07.000Z","dependencies_parsed_at":"2025-02-07T09:42:26.080Z","dependency_job_id":null,"html_url":"https://github.com/ArnavK-09/unwrap-go","commit_stats":null,"previous_names":["arnavk-09/unwrap-go"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavK-09%2Funwrap-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavK-09%2Funwrap-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavK-09%2Funwrap-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavK-09%2Funwrap-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArnavK-09","download_url":"https://codeload.github.com/ArnavK-09/unwrap-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239322036,"owners_count":19619822,"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":["bun","cross","error","handler","jsr","lib","node","npm","package","pkg","typescript","workflows"],"created_at":"2025-02-17T16:23:15.030Z","updated_at":"2026-02-19T19:03:27.625Z","avatar_url":"https://github.com/ArnavK-09.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e🫧 unwrap-go 🫧\u003c/h1\u003e\n\u003ch2 align=\"center\"\u003eGo-like Error Handling for TypeScript/JavaScript\u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"hero\" width=\"450\" src=\"https://emoji-route.deno.dev/gif/🫧\" /\u003e\n\u003c/p\u003e\n\n\u003e [!NOTE]\n\u003e\n\u003e unwrap-go brings Go-style error handling to TypeScript and JavaScript, offering a clean and predictable way to handle errors using Result tuples. This approach eliminates the need for try-catch blocks and provides a more functional approach to error management.\n\n## 🌟 Features\n\n\u003e **unwrap-go** features intro:\n\n- **Go-Style Error Handling** – Uses tuple returns (`[data, error]`) similar to Go's approach, making error handling more explicit and predictable\n- **Promise Support** – Built-in support for handling asynchronous operations with the same elegant syntax\n- **Type Safety** – Full TypeScript support with generic types for both success and error cases\n- **Zero Dependencies** – Lightweight implementation with no external dependencies\n- **Synchronous Support** – Handle both async and sync operations with consistent patterns\n\n## 🧨 Registries\n\n- **[jsr.io/@arnavk-09/unwrap-go](https://jsr.io/@arnavk-09/unwrap-go)**\n- **[npmjs.com/package/@arnavk-09/unwrap-go](https://www.npmjs.com/package/@arnavk-09/unwrap-go)**\n\n## 💻 Installation\n\n\u003e You can add **unwrap-go** with one command via:\n\n###### terminal\n\n```bash\nnpm install @arnavk-09/unwrap-go\ndeno add jsr:@arnavk-09/unwrap-go\nbun add @arnavk-09/unwrap-go\npnpm add @arnavk-09/unwrap-go\nyarn add @arnavk-09/unwrap-go\n\n```\n\n\u003cp align=\"center\"\u003eOR\u003c/p\u003e\n\n###### Deno\n\n```bash\ndeno add jsr:@arnavk-09/unwrap-go\n```\n\n###### Npx\n\n```bash\nnpm install @arnavk-09/unwrap-go\n```\n\n###### Bun\n\n```bash\nbun add @arnavk-09/unwrap-go\n```\n\n###### Pnpm\n\n```bash\npnpm add @arnavk-09/unwrap-go\n```\n\n###### Yarn\n\n```bash\nyarn add @arnavk-09/unwrap-go\n```\n\n## 🚀 Usage\n\n```typescript\nimport { unwrapPromise, unwrapSync } from \"@arnavk-09/unwrap-go\";\n\n// Async example\nasync function fetchData() {\n  const [data, err] = await unwrapPromise(\n    fetch(\"https://api.example.com/data\"),\n  );\n  if (err) {\n    console.error(\"Failed to fetch:\", err);\n    return;\n  }\n  console.log(\"Data:\", data);\n}\n\n// Sync example\nfunction divide(a: number, b: number) {\n  const [result, err] = unwrapSync(() =\u003e {\n    if (b === 0) throw new Error(\"Division by zero\");\n    return a / b;\n  });\n  if (err) {\n    console.error(\"Division failed:\", err);\n    return;\n  }\n  console.log(\"Result:\", result);\n}\n```\n\n## 📚 API Reference\n\n| Function              | Description                                                | Parameters                           | Return Type              |\n| --------------------- | ---------------------------------------------------------- | ------------------------------------ | ------------------------ |\n| `unwrapPromise\u003cT, E\u003e` | Wraps a promise to return a Result tuple                   | `promise: Promise\u003cT\u003e`                | `Promise\u003cResult\u003cT, E\u003e\u003e`  |\n| `unwrapSync\u003cT, E\u003e`    | Executes a synchronous function and returns a Result tuple | `fn: () =\u003e T`                        | `Result\u003cT, E\u003e`           |\n| `Result\u003cT, E\u003e`        | Type representing either success (T) or error (E)          | `T`: Success type\u003cbr\u003e`E`: Error type | `[T, null] \\| [null, E]` |\n\n## 🛣️ Roadmap\n\n|       Task        | Status |\n| :---------------: | :----: |\n|   🧪 Add tests    |   🔴   |\n| 🧪 Publish To JSR |   🟢   |\n| 🧪 Publish To NPM |   🟢   |\n\n## 💻 Contributing\n\n\u003e [!TIP]  \n\u003e We welcome contributions to improve **unwrap-go**! If you have suggestions, bug fixes, or new feature ideas, follow these steps:\n\n1. **Fork the Repository** you\n   Click the **Fork** button at the top-right of the repo page.\n\n2. **Clone Your Fork**  \n   Clone the repo locally: YOU\n\n   ```bash\n   git clone https://github.com/ArnavK-09/unwrap-go.git\n   ```\n\n3. **Create a Branch**  \n   Create a new branch for your changes:\n\n   ```bash\n   git checkout -b your-feature-branch\n   ```\n\n4. **Make Changes**  \n   Implement your changes (bug fixes, features, etc.).\n\n5. **Commit and Push**  \n   Commit your changes and push the branch:\n\n   ```bash\n   git commit -m \"feat(scope): description\"\n   git push origin your-feature-branch\n   ```\n\n6. **Open a Pull Request**  \n   Open a PR with a detailed description of your changes.\n\n7. **Collaborate and Merge**  \n   The maintainers will review your PR, request changes if needed, and merge it once approved.\n\n## 🙋‍♂️ Issues\n\nFound a bug or need help? Please create an issue on the [GitHub repository](https://github.com/ArnavK-09/unwrap-go/issues) with a detailed description.\n\n## 👤 Author\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n        \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/ArnavK-09\"\u003e\u003cimg src=\"https://github.com/ArnavK-09.png?s=100\" width=\"130px;\" alt=\"Arnav K\"/\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ArnavK-09\"\u003ch4\u003e\u003cb\u003eArnav K\u003c/b\u003e\u003c/h3\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n---\n\n\u003ch2 align=\"center\"\u003e📄 License\u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003eunwrap-go\u003c/strong\u003e is licensed under the \u003ccode\u003eUnlicense\u003c/code\u003e License. See the \u003ca href=\"https://github.com/ArnavK-09/unwrap-go/blob/main/LICENSE\"\u003eLICENSE\u003c/a\u003e file for more details.\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003e🌟 If you find this project helpful, please give it a star on GitHub! 🌟\u003c/strong\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnavk-09%2Funwrap-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnavk-09%2Funwrap-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnavk-09%2Funwrap-go/lists"}