UNPKG

511 BJavaScriptView Raw
1
2import {TokenType as tt} from "../parser/tokenizer/types";
3
4import Transformer from "./Transformer";
5
6export default class OptionalCatchBindingTransformer extends Transformer {
7 constructor( tokens, nameManager) {
8 super();this.tokens = tokens;this.nameManager = nameManager;;
9 }
10
11 process() {
12 if (this.tokens.matches2(tt._catch, tt.braceL)) {
13 this.tokens.copyToken();
14 this.tokens.appendCode(` (${this.nameManager.claimFreeName("e")})`);
15 return true;
16 }
17 return false;
18 }
19}