removeMaybeImportAttributes.js 784 B

12345678910111213141516171819202122
  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _keywords = require('../parser/tokenizer/keywords');
  2. var _types = require('../parser/tokenizer/types');
  3. /**
  4. * Starting at a potential `with` or (legacy) `assert` token, remove the import
  5. * attributes if they exist.
  6. */
  7. function removeMaybeImportAttributes(tokens) {
  8. if (
  9. tokens.matches2(_types.TokenType._with, _types.TokenType.braceL) ||
  10. (tokens.matches2(_types.TokenType.name, _types.TokenType.braceL) && tokens.matchesContextual(_keywords.ContextualKeyword._assert))
  11. ) {
  12. // assert
  13. tokens.removeToken();
  14. // {
  15. tokens.removeToken();
  16. tokens.removeBalancedCode();
  17. // }
  18. tokens.removeToken();
  19. }
  20. } exports.removeMaybeImportAttributes = removeMaybeImportAttributes;