-
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Original issue submitted by @xtuc in babel/babylon#610
This issue is to keep track of the implementation in the parser of this proposal.
Champions: Brian Terlson (Microsoft, @bterlson), Sebastian Markbåge (Facebook, @sebmarkbage)
Spec Repo: https://github.com/tc39/proposal-pattern-matching
Remember that proposals are just that; subject to change until Stage 4!
Examples
let length = vector => match (vector) {
{ x, y, z }: Math.sqrt(x ** 2 + y ** 2 + z ** 2),
{ x, y }: Math.sqrt(x ** 2 + y ** 2),
[...]: vector.length,
else: {
throw new Error("Unknown vector type");
}
}
let isVerbose = config => match (config) {
{ output: { verbose: true } }: true,
else: false
}
let outOfBoundsPoint = p => match (p) {
{ x > 100, y }: true,
{ x, y > 100 }: true,
else: false
}
You can find more example in the spec repo.
Parsing
https://github.com/babel/babylon/blob/master/CONTRIBUTING.md#creating-a-new-plugin-spec-new
- Babylon plugin:
patternMatching
Transform
- Babel plugin
krzkaczor, CYBAI, arialpew, octet-stream, andreicek and 39 moreantonmedv