swissmanu / pattern-matching-with-typescript

TypeScript does not have any pattern matching functionality built in. This article shows several ways how you can replicate the core of a simple pattern matcher using a few simple structures and functions within TypeScript. Resulting code will have improved maintainability and better runtime type safety when done right.

Home Page:https://alabor.me/2017/07/05/pattern-matching-with-typescript.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pattern Matching with TypeScript

TypeScript does not have any pattern matching functionality built in. This article shows several ways how you can replicate the core of a simple pattern matcher using a few simple structures and functions within TypeScript.

Resulting code will have improved maintainability and better runtime type safety when done right.

This is the backing repository for the article "Pattern Matching with TypeScript" published under https://alabor.me/2017/07/05/pattern-matching-with-typescript.html

Examples

The examples/ directory contains example code which goes along with the article read. Every example is fully executable.

You can run the examples by cloning or downloading this repository. Run npm install to install TypeScript and Jest. npm test executes the test suite for the examples.

😎 Pro tip: Run npm test -- --watch if you want to tinker with the code and rerun the test suite automatically.

Article

Github Pages is used to serve the article to you. You find its text and all assets in the gh-pages branch.

Credits

❤️ Thanks to my reviewers for advises and proofreading:

About

TypeScript does not have any pattern matching functionality built in. This article shows several ways how you can replicate the core of a simple pattern matcher using a few simple structures and functions within TypeScript. Resulting code will have improved maintainability and better runtime type safety when done right.

https://alabor.me/2017/07/05/pattern-matching-with-typescript.html

License:MIT License


Languages

Language:JavaScript 100.0%