This repository has been archived on 2024-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
fediversity.eu/node_modules/sucrase/dist/esm/transformers/OptionalCatchBindingTransformer.js

20 lines
511 B
JavaScript
Raw Normal View History

2024-03-26 16:28:28 +01:00
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;
}
}