{"id":30845361,"url":"https://github.com/mikkurogue/ferrocore","last_synced_at":"2025-09-06T23:08:50.430Z","repository":{"id":294408174,"uuid":"986902859","full_name":"mikkurogue/ferrocore","owner":"mikkurogue","description":"A light weight 0 dependency Option/Result library for typescript","archived":false,"fork":false,"pushed_at":"2025-07-15T09:18:15.000Z","size":153,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-06T21:49:43.300Z","etag":null,"topics":["error","error-as-values","none","option","result","some","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@mikkurogue/ferrocore","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikkurogue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-05-20T09:37:03.000Z","updated_at":"2025-07-15T09:18:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"1b9eb312-ccb0-4549-bc88-e60ab66014ad","html_url":"https://github.com/mikkurogue/ferrocore","commit_stats":null,"previous_names":["mikkurogue/option-ts","mikkurogue/ferrocore"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mikkurogue/ferrocore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikkurogue%2Fferrocore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikkurogue%2Fferrocore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikkurogue%2Fferrocore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikkurogue%2Fferrocore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikkurogue","download_url":"https://codeload.github.com/mikkurogue/ferrocore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikkurogue%2Fferrocore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273974082,"owners_count":25200587,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"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":["error","error-as-values","none","option","result","some","typescript"],"created_at":"2025-09-06T23:08:48.342Z","updated_at":"2025-09-06T23:08:50.419Z","avatar_url":"https://github.com/mikkurogue.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @mikkurogue/ferrocore\n\nA TypeScript library providing Rust-inspired `Option` and `Result` types for robust error handling and explicit value presence.\n\n## Features\n\n- **`Option\u003cT\u003e` Type:** Represents the presence (`Some`) or absence (`None`) of a value, helping to eliminate `null` and `undefined` related bugs.\n- **`Result\u003cT, E\u003e` Type:** Encapsulates either a successful value (`Ok`) or an error (`Err`), promoting explicit error handling over exceptions.\n- **Functional API:** Provides `map`, `flatMap`, `orElse`, `filter`, and `match` functions for composing operations on `Option` and `Result` types.\n- **`fromThrowable`:** A utility to convert potentially throwing functions into `Option` or `Result` returning functions, enabling a more functional error handling style.\n- **Clean API:** Designed for ease of use and integration into existing TypeScript projects.\n\n## Installation\n\n```bash\nnpm install @mikkurogue/ferrocore\n# or\nyarn add @mikkurogue/ferrocore\n```\n\n## Usage\n\n### Option Example\n\n```typescript\nimport { Option, Some, None, ifSome, unwrapOption, unwrapOrOption } from '@mikkurogue/ferrocore/option';\n\nfunction getUserById(id: string): Option\u003c{ name: string }\u003e {\n  if (id === \"123\") {\n    return Some({ name: \"Alice\" });\n  }\n  return None();\n}\n\nconst user = getUserById(\"123\");\n\nifSome(user, (u) =\u003e {\n  console.log(`User found: ${u.name}`);\n});\n\nconst userName = unwrapOrOption(user, { name: \"Guest\" }).name;\nconsole.log(userName); // Alice\n\nconst nonExistentUser = getUserById(\"456\");\nconst defaultUserName = unwrapOrOption(nonExistentUser, { name: \"Guest\" }).name;\nconsole.log(defaultUserName); // Guest\n```\n\n### Result Example\n\n```typescript\nimport { Result, Ok, Err, match, fromThrowable } from '@mikkurogue/ferrocore/result';\n\nfunction divide(a: number, b: number): Result\u003cnumber, string\u003e {\n  if (b === 0) {\n    return Err(\"Cannot divide by zero\");\n  }\n  return Ok(a / b);\n}\n\nconst division1 = divide(10, 2);\nmatch(\n  division1,\n  (val) =\u003e console.log(`Result: ${val}`), // Result: 5\n  (err) =\u003e console.error(`Error: ${err}`)\n);\n\nconst division2 = divide(10, 0);\nmatch(\n  division2,\n  (val) =\u003e console.log(`Result: ${val}`),\n  (err) =\u003e console.error(`Error: ${err}`) // Error: Cannot divide by zero\n);\n\nconst safeParseJson = fromThrowable(\n  JSON.parse,\n  (e) =\u003e (e as Error).message\n);\n\nconst parsedJson = safeParseJson('{\"key\": \"value\"}');\nmatch(\n  parsedJson,\n  (data) =\u003e console.log(\"Parsed JSON:\", data), // Parsed JSON: { key: 'value' }\n  (error) =\u003e console.error(\"JSON Error:\", error)\n);\n```\n\n## Documentation\n\nFor more detailed information and examples, please refer to the [full documentation](./docs/README.md).\n\n## Build System\n\nThis project uses the standard TypeScript compiler (`tsc`) for its build system.\n\n## Contributing\n\nContributions are welcome, in any form you'd like.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikkurogue%2Fferrocore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikkurogue%2Fferrocore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikkurogue%2Fferrocore/lists"}