{"id":50707924,"url":"https://github.com/armadacore/essentials","last_synced_at":"2026-06-09T13:01:24.447Z","repository":{"id":356692841,"uuid":"1224589124","full_name":"armadacore/essentials","owner":"armadacore","description":"TypeScript essentials for explicit error and absence handling - Option, Result, typed Exceptions and optional Callbacks the compiler actually enforces.","archived":false,"fork":false,"pushed_at":"2026-05-09T08:17:56.000Z","size":341,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-09T10:29:33.442Z","etag":null,"topics":["discriminated-union","error-handling","exception","functional-programming","monad","nullsafety","option","result","ts-essentials","type-safety"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@armadacore/essentials","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/armadacore.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-29T12:35:15.000Z","updated_at":"2026-05-09T08:17:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/armadacore/essentials","commit_stats":null,"previous_names":["armadacore/essentials"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/armadacore/essentials","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armadacore%2Fessentials","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armadacore%2Fessentials/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armadacore%2Fessentials/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armadacore%2Fessentials/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/armadacore","download_url":"https://codeload.github.com/armadacore/essentials/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armadacore%2Fessentials/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34107866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"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":["discriminated-union","error-handling","exception","functional-programming","monad","nullsafety","option","result","ts-essentials","type-safety"],"created_at":"2026-06-09T13:01:23.447Z","updated_at":"2026-06-09T13:01:24.437Z","avatar_url":"https://github.com/armadacore.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @armadacore/essentials\n\n[![npm version](https://img.shields.io/npm/v/@armadacore/essentials.svg)](https://www.npmjs.com/package/@armadacore/essentials)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/armadacore/essentials/blob/master/LICENSE)\n[![node](https://img.shields.io/node/v/@armadacore/essentials.svg)](https://nodejs.org)\n\n\u003e This library exists because I wanted Rust's robustness and explicit control flow in TypeScript. TypeScript's type system is strong enough to express \"this value might be missing\" or \"this call might fail\" — but the language itself doesn't force you to handle those cases. `null`, `undefined`, and thrown exceptions slip through type signatures and surface as runtime bugs. `essentials` brings the patterns that solve this in Rust — `Option`, `Result`, typed exceptions — to TypeScript in a form that the compiler actually enforces.\n\n## The problem this solves\n\nIn an average TypeScript codebase, three things tend to go wrong silently:\n\n1. **Absence is invisible.** A function returns `User | null` or `User | undefined`. The caller forgets the check. The bug shows up in production.\n2. **Failure is invisible.** A function throws. The signature says `: User`. Nothing in the type system tells the caller that this call can blow up, or with what.\n3. **Errors lose context.** An exception bubbles up, gets re-thrown, and somewhere along the way the original cause is lost — leaving you with a stack trace that points nowhere useful.\n\n`essentials` makes all three of these explicit at the type level. You can't accidentally ignore an absent value, you can't accidentally ignore a failure, and you can't accidentally drop the cause of an error.\n\n## What you get\n\n- **`Option\u003cT\u003e`** — a value that is either `Some(value)` or `None`. Replaces `T | null` and `T | undefined` in your domain types. The compiler forces you to handle both branches before you can touch the value.\n- **`Result\u003cT\u003e`** — a value that is either `Ok(value)` or `Err(exception)`. Replaces \"this function throws\". The failure becomes part of the return type, with a fixed `Exception` error channel so handling stays uniform.\n- **`Exception`** — a typed error hierarchy with HTTP-status awareness, an `info` discriminator, and proper `cause` propagation. Built so you can throw, catch, re-wrap, and serialize without losing the original failure.\n- **`Callback\u003cT\u003e`** — an `Option`-shaped wrapper for optional function values, so \"the consumer might or might not have provided a handler\" stops being a special case.\n\nAll public API is documented inline via TSDoc — IDE hover shows the full contract per symbol.\n\n## The benefit, in one snippet\n\n```typescript\n// Before — the compiler is fine with all of this. Production isn't.\nconst findUser = (id: string): User | null =\u003e { /* ... */ };\n\nconst user = findUser(id);\nconsole.log(user.name);   // runtime: Cannot read properties of null\n\n// After — the compiler refuses to let you ignore the absent case.\nconst findUser = (id: string): IOption\u003cUser\u003e =\u003e { /* ... */ };\n\nconst userOption = findUser(id);\nuserOption.onSome((user) =\u003e console.log(user.name));\nuserOption.onNone(() =\u003e console.log(\"not found\"));\n```\n\nThe same shift applies to fallible operations (`Result` instead of `throw`) and to error handling (`Exception` instead of bare `Error`). The pattern is always the same: **make the failure mode part of the type, so the compiler enforces handling**.\n\n## Documentation\n\nFull documentation lives in the [project wiki](https://github.com/armadacore/essentials/wiki) — start there for the per-building-block pages, common patterns and the wire-format / cross-monad reference.\n\nEvery public symbol is also annotated with TSDoc — your IDE hover shows the same contract that the wiki documents.\n\n## Install\n\n```bash\nnpm install @armadacore/essentials\n```\n\nRequires Node.js `\u003e=20` and TypeScript `~5.7`.\n\n## License\n\nSee [LICENSE](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmadacore%2Fessentials","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmadacore%2Fessentials","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmadacore%2Fessentials/lists"}