{"id":18224925,"url":"https://github.com/iamsebastiandev/handleasync","last_synced_at":"2026-02-11T22:37:43.802Z","repository":{"id":164448785,"uuid":"639148939","full_name":"IamSebastianDev/handleAsync","owner":"IamSebastianDev","description":"Rust Style Error Handling for TypeScript","archived":false,"fork":false,"pushed_at":"2025-03-01T19:23:43.000Z","size":973,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T16:31:48.556Z","etag":null,"topics":["async","error-handling","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/IamSebastianDev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"license.md","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-05-10T21:37:24.000Z","updated_at":"2024-12-03T18:02:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"3292968f-d342-4017-8271-00246019dc91","html_url":"https://github.com/IamSebastianDev/handleAsync","commit_stats":{"total_commits":65,"total_committers":3,"mean_commits":"21.666666666666668","dds":0.3846153846153846,"last_synced_commit":"547378667041999cc0b4238fca1b26cebb931cc0"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamSebastianDev%2FhandleAsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamSebastianDev%2FhandleAsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamSebastianDev%2FhandleAsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamSebastianDev%2FhandleAsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IamSebastianDev","download_url":"https://codeload.github.com/IamSebastianDev/handleAsync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271921,"owners_count":21075800,"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":["async","error-handling","typescript"],"created_at":"2024-11-04T02:05:24.332Z","updated_at":"2026-02-11T22:37:38.771Z","avatar_url":"https://github.com/IamSebastianDev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- @format --\u003e\n\n# @iasd/handle-async\n\nA simple, yet powerful, utility function to handle async operations, providing a clean and consistent API.\n\n## 🚀 Getting started\n\nTo use the utility functions with npm and/or a bundler such as webpack or rollup, install it via yarn or npm:\n\n```bash\nyarn add @iasd/handle-async\n# or use npm\nnpm install @iasd/handle-async\n```\n\nYou can also use it directly in the browser and include it via CDN (or locally, if you like).\n\n```html\n\u003chead\u003e\n    ...\n    \u003c!-- as a local file --\u003e\n    \u003cscript src=\"./your/path/to/handleAsync.browser.min.js\"\u003e\u003c/script\u003e\n    \u003c!-- or via CDN --\u003e\n    \u003cscript src=\"http://unpkg.com/@iasd/handle-async\"\u003e\u003c/script\u003e\n    ...\n\u003c/head\u003e\n```\n\n## 🔧 Usage\n\n### Imports and Global\n\nThe library provides exports for modern `import` syntax as well as exports for the `require` syntax.\n\n```js\n// node require syntax\nconst { handleAsync } = require('@iasd/handle-async');\n\n// modern es6 style syntax\nimport { handleAsync } from '@iasd/handle-async';\n```\n\nIn case you included the library file locally or via CDN, the `handleAsync` object is globally available.\n\n```js\nconst { handleAsync } = handleAsync;\n```\n\n### Handling Async Calls\n\nUse the `handleAsync` function to handle asynchronous operations in a safe manner.\n\n```ts\nimport { handleAsync } from '@iasd/handle-async';\n\n// Create a async runner that returns a boolean\nconst asyncRunner = () =\u003e new Promise((res) =\u003e window.setTimeout(() =\u003e res(true), 5000));\n// Retrieve the result from the runner\n\nconst result = await handleAsync(asyncRunner, {\n    Ok: (value) =\u003e value, // Use the `Ok` handler to return or transform the value\n    Err: (err) =\u003e false, // Use the `Err` handler to handle any error or rethrow if necessary\n});\n\n// Result will be either `true`, if the runner encountered no issue,\n// or `false` if it was handled by the error handler.\nconsole.log(result);\n```\n\n\u003e Tip: The value returned by the `Err` handler must be of the same type as the value returned by the `Ok` handler, to enforce correct handling.\n\n## Contributing\n\nIf you would like to contribute, take a look at the [contribution guide](./contributing.md).\n\n## License\n\n`handleAsync` is licensed under the [MIT License](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamsebastiandev%2Fhandleasync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamsebastiandev%2Fhandleasync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamsebastiandev%2Fhandleasync/lists"}