{"id":16095856,"url":"https://github.com/joakin/sum-types","last_synced_at":"2025-10-16T18:16:39.421Z","repository":{"id":57121582,"uuid":"129314295","full_name":"joakin/sum-types","owner":"joakin","description":"Sum types for JS","archived":false,"fork":false,"pushed_at":"2018-11-15T10:23:09.000Z","size":54,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-16T19:26:40.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/joakin.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}},"created_at":"2018-04-12T21:43:36.000Z","updated_at":"2019-09-25T04:08:31.000Z","dependencies_parsed_at":"2022-08-24T06:31:08.026Z","dependency_job_id":null,"html_url":"https://github.com/joakin/sum-types","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakin%2Fsum-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakin%2Fsum-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakin%2Fsum-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakin%2Fsum-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joakin","download_url":"https://codeload.github.com/joakin/sum-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221708536,"owners_count":16867613,"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-10-09T17:09:14.665Z","updated_at":"2025-10-16T18:16:34.390Z","avatar_url":"https://github.com/joakin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @joakin/sum-types\n\n```\nnpm install @joakin/sum-types\n```\n\n`sum-types` provides union|adt|sum types for JS.\n\nExhaustiveness checking, `Maybe` and `Result` types, and a nice API.\n\n[Read the docs](https://joakin.github.io/sum-types)\n\n```js\nimport { Type } from \"@joakin/sum-types\";\n\nconst State = Type({\n  Loading: [],\n  Success: [\"data\"],\n  Error: [\"error\"]\n});\n\nlet state1 = State.Loading();\nlet state2 = State.Success(42);\nlet state3 = State.Error(new Error(\"Failed\"));\n\nfunction toString(state) {\n  return state.match({\n    Loading: _ =\u003e \"Loading\",\n    Success: data =\u003e `Got data ${data}`,\n    Error: err =\u003e `Got error: ${err}`\n  });\n}\n\n// Or\n\nconst toString = State.match({\n  Loading: _ =\u003e \"Loading\",\n  Success: data =\u003e `Got data ${data}`,\n  Error: err =\u003e `Got error: ${err}`\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakin%2Fsum-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoakin%2Fsum-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakin%2Fsum-types/lists"}