模式匹配(pattern matching)是 lisp 、rust 、scala 、erlang 等语言中的常见语法,不过 JavaScript 一直未支持这个特性,虽然 tc39 早有相关的题案 https://github.com/tc39/proposal-pattern-matching ,不过目前进展缓慢,由于本人研发了 Babel 插件用于支持在 JavaScript 使用模式匹配的能力,目前完善程度还是比较高的,很接近其他主流语言的 pattern-matching
github 链接 https://github.com/iptop/babel-plugin-proposal-pattern-matching
github 链接 https://github.com/iptop/babel-plugin-proposal-pattern-matching