{"id":24612688,"url":"https://github.com/matchbook-ts/matchbook-ts","last_synced_at":"2025-05-06T21:48:19.252Z","repository":{"id":43449059,"uuid":"255237325","full_name":"matchbook-ts/matchbook-ts","owner":"matchbook-ts","description":"pattern matching in javascript \u0026 typescript made easy","archived":false,"fork":false,"pushed_at":"2023-01-06T03:17:49.000Z","size":10744,"stargazers_count":34,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T03:15:21.009Z","etag":null,"topics":["ava","declarative","declarative-programming","easy","functional","functional-programming","functions","javascript","library","matchbook","no-dependencies","package","pattern-matching","reactive-programming","simple","small","tiny","tiny-library","ts","typescript"],"latest_commit_sha":null,"homepage":"https://matchbook-ts.github.io/matchbook-ts/docs/","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/matchbook-ts.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}},"created_at":"2020-04-13T05:14:34.000Z","updated_at":"2025-03-20T09:08:40.000Z","dependencies_parsed_at":"2023-02-05T05:01:34.310Z","dependency_job_id":null,"html_url":"https://github.com/matchbook-ts/matchbook-ts","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matchbook-ts%2Fmatchbook-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matchbook-ts%2Fmatchbook-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matchbook-ts%2Fmatchbook-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matchbook-ts%2Fmatchbook-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matchbook-ts","download_url":"https://codeload.github.com/matchbook-ts/matchbook-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252776480,"owners_count":21802462,"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":["ava","declarative","declarative-programming","easy","functional","functional-programming","functions","javascript","library","matchbook","no-dependencies","package","pattern-matching","reactive-programming","simple","small","tiny","tiny-library","ts","typescript"],"created_at":"2025-01-24T20:24:48.242Z","updated_at":"2025-05-06T21:48:19.245Z","avatar_url":"https://github.com/matchbook-ts.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logo](assets/banner.png)\n\n# 🔥 matchbook\n## pattern matching in typescript \u0026 javascript made easy\n\nmatchbook is a lightweight \u0026 easy to use pattern matching library,\nfor TypeScript and JavaScript.\n\nIf you want to know more about matchbook,\n[check out the docs][api_docs] or [read on](#table-of-contents)!\n\nIf you want to start using matchbook, install it like any other npm package:\n\n`npm i @matchbook/ts`\n\n---\n\n![it's as easy as a-b-c 1-2-3](assets/readme-samples/static/abc_123.snippet.png)\n\n### badges\n|npm                                                |code                                               |other|\n|---                                                |---                                                |---|\n|[![npm version][npm_ver_badge]][npm_link]          |![top lang][lang_badge]                            |[![build][build_badge]][build_link]|\n|[![pkg size][npm_size_badge]][npm_link]            |[![google typescript style][gts_badge]][gts_url]   |![license][license_badge]|\n|[![source rank][source_rank_badge]][libraries_io]  |[![codacy][codacy_badge]][codacy_link]             | |\n|                                                   |[![codecov][codecov_badge]][codecov_link]          | |\n\n## table of contents\n\n-   [what matchbook does for you](#what-matchbook-does-for-you)\n\n-   [what you can do for matchbook](#what-you-can-do-for-matchbook)\n\n-   [pattern matching explained](#pattern-matching-explained)\n\n-   [matchbook at a glance](#matchbook-at-a-glance)\n\n-   [matchbook at a slightly longer glance (examples)](#matchbook-at-a-slightly-longer-glance)\n    -   [switching on part of an object](#switching-on-part-of-an-object)\n    -   [switching on an `enum`](#switching-on-an-enum)\n    -   [acting on the type of an Event](#acting-on-the-type-of-an-event)\n    -   [matching if a value is an `instanceof` a constructor](#matching-if-a-value-is-an-instanceof-a-constructor)\n\n## what matchbook does for you\n_(list is in no particular order)_\n\n-   **expressive** - pattern matching helps you write **less code** that's **more expressive** than if/else trees\n-   **simple** - API is just 5 functions, 1 error class, and some stylistic aliases for the core functions\n-   **powerful** - type inference backed by Typescript\n-   **well documented** - [check out the docs here!][api_docs]\n-   **low cost** - no runtime dependencies, \u0026 small package size\n-   **reliable** - 100% unit test coverage, with all pushes verified via Travis CI \n\n## what you can do for matchbook\n### use it!\n\nThe project is very minimal, with the intent of starting with a very simple \u0026 focused API\nthat grows with its needs.\n\n### ask questions!\n\nIf you have any questions, any feedback, or just want to shoot the shirt,\n[open an issue][new_issue] of type `question`, and we'll do our best to answer quickly!\n\n## pattern matching explained\nPattern matching is a  modern language feature that is similar to a `switch` / `case` statement.\n\nWith pattern matching, you can switch on the _type_ of the incoming value,\nmeaning you can reduce a lot of extra-verbose if-else branches just by\nreplacing them with pattern matching statements.\n\nYou might consider using pattern matching if you find you're switching on types\nor states frequently, and want to handle the different cases in a \nconcise and expressive way.\n\nThis project takes heavy inspiration from [Rust's pattern matching idiom][rust_match].\n\n## matchbook at a glance\nwant to know more? [read the docs][api_docs]!\n![matchbook at a glance](assets/readme-samples/static/10-000-feet.snippet.png)\n\n## matchbook at a slightly longer glance\nwant to know more? [read the docs][api_docs]!\n\n### switching on part of an object\n![enum example](assets/readme-samples/static/structure.snippet.png)\n\n### switching on an `enum`\n![enum example](assets/readme-samples/static/enum.snippet.png)\n\n### acting on the type of an Event\n[Type guards][type_guard]\n![enum example](assets/readme-samples/static/type_guard.snippet.png)\n\n### matching if a value is an `instanceof` a constructor\n![enum example](assets/readme-samples/static/ctor.snippet.png)\n\n[api_docs]: https://matchbook-ts.github.io/matchbook-ts/docs/\n[rust_match]: https://doc.rust-lang.org/book/ch06-02-match.html\n[codecov_link]: https://codecov.io/gh/matchbook-ts/matchbook-ts\n[codecov_badge]: https://codecov.io/gh/matchbook-ts/matchbook-ts/branch/master/graph/badge.svg\n[build_link]: https://travis-ci.org/matchbook-ts/matchbook-ts\n[build_badge]: https://travis-ci.org/matchbook-ts/matchbook-ts.svg?branch=master\n[npm_ver_badge]: https://img.shields.io/npm/v/@matchbook/ts\n[npm_size_badge]: https://img.shields.io/bundlephobia/min/@matchbook/ts\n[npm_link]: https://www.npmjs.com/package/@matchbook/ts\n[lang_badge]: https://img.shields.io/github/languages/top/matchbook-ts/matchbook-ts\n[license_badge]: https://img.shields.io/github/license/matchbook-ts/matchbook-ts\n[source_rank_badge]: https://img.shields.io/librariesio/sourcerank/npm/@matchbook/ts\n[libraries_io]: https://libraries.io/npm/@matchbook%2Fts\n[codacy_badge]: https://api.codacy.com/project/badge/Grade/dd3aa51feb4b4b9988d2a1c9ea543187\n[codacy_link]: https://www.codacy.com/gh/matchbook-ts/matchbook-ts?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=matchbook-ts/matchbook-ts\u0026amp;utm_campaign=Badge_Grade\n[new_issue]: https://github.com/matchbook-ts/matchbook-ts/issues/new\n[gts_badge]: https://img.shields.io/badge/code%20style-google-blueviolet.svg\n[gts_url]: https://github.com/google/gts\n[type_guard]: https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatchbook-ts%2Fmatchbook-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatchbook-ts%2Fmatchbook-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatchbook-ts%2Fmatchbook-ts/lists"}