printer-notifications/node_modules/sucrase/dist/esm/transformers/OptionalCatchBindingTransformer.js
2023-11-13 16:10:04 -05:00

20 lines
511 B
JavaScript

import {TokenType as tt} from "../parser/tokenizer/types";
import Transformer from "./Transformer";
export default class OptionalCatchBindingTransformer extends Transformer {
constructor( tokens, nameManager) {
super();this.tokens = tokens;this.nameManager = nameManager;;
}
process() {
if (this.tokens.matches2(tt._catch, tt.braceL)) {
this.tokens.copyToken();
this.tokens.appendCode(` (${this.nameManager.claimFreeName("e")})`);
return true;
}
return false;
}
}