{"id":16227671,"url":"https://github.com/el3um4s/match","last_synced_at":"2026-04-10T21:04:59.440Z","repository":{"id":40695313,"uuid":"409192717","full_name":"el3um4s/match","owner":"el3um4s","description":"Alternative to JavaScript’s switch statement with a functional twist","archived":false,"fork":false,"pushed_at":"2023-01-08T17:43:58.000Z","size":789,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T19:17:08.911Z","etag":null,"topics":["functional-programming","javascript","js","npm","npm-package","switch","switch-case","ts","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/el3um4s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["el3um4s"],"patreon":"el3um4s","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.me/el3um4s"]}},"created_at":"2021-09-22T12:18:39.000Z","updated_at":"2022-06-26T21:10:26.000Z","dependencies_parsed_at":"2023-02-08T06:50:12.586Z","dependency_job_id":null,"html_url":"https://github.com/el3um4s/match","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/el3um4s","download_url":"https://codeload.github.com/el3um4s/match/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247778656,"owners_count":20994518,"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":["functional-programming","javascript","js","npm","npm-package","switch","switch-case","ts","typescript"],"created_at":"2024-10-10T12:53:30.263Z","updated_at":"2026-04-10T21:04:59.410Z","avatar_url":"https://github.com/el3um4s.png","language":"TypeScript","readme":"# @el3um4s/match\nAlternative to JavaScript’s switch statement with a functional twist\n\nBased on [Alternative to JavaScript’s switch statement with a functional twist](https://codeburst.io/alternative-to-javascripts-switch-statement-with-a-functional-twist-3f572787ba1c)\n\nNPM: [@el3um4s/match](https://www.npmjs.com/package/@el3um4s/match)\n### Install and use the package\n\nTo use the package in a project:\n\n```bash\nnpm i @el3um4s/match\n```\n\nand then in a file:\n\n```ts\nimport match from \"@el3um4s/match\";\n\nconst handleShape = (shape, w) =\u003e area(shape,w);\n\nfunction area (type = \"Circle\", width = 2) {\n  return match(type)\n          .on(type =\u003e type.toLowerCase() === \"circle\", () =\u003e {\n              return Math.PI * (width / 2) ** 2;\n            })\n          .on(type =\u003e type.toLowerCase() === \"square\", () =\u003e width ** 2)\n          .otherwise(() =\u003e 0);\n};\n\nhandleShape(\"Square\", 3);\n```\n","funding_links":["https://github.com/sponsors/el3um4s","https://patreon.com/el3um4s","https://www.paypal.me/el3um4s"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fel3um4s%2Fmatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fel3um4s%2Fmatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fel3um4s%2Fmatch/lists"}