Match
A basic port of Rust's match function.
Install
npm install rust-match --save
You can get the UMD build from /umd
, or use it in a script tag from npmcdn:
<script src="https://npmcdn.com/rust-match/umd/match.min.js"></script>
Examples
Play around on JSFiddle
let message = 'hello'let response = console // prints 'the value is hello' //numbers and spaces are more verboselet number = '26'
Exhaustive Checking
//throws: error: non-exhaustive patterns: `_` not covered, just like rust!
Usage with Redux
This also turns out to be a nice alternative to using switch statements in redux!
{ return }