You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.5 KiB

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isReservedWord = isReservedWord;
  6. exports.isStrictReservedWord = isStrictReservedWord;
  7. exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
  8. exports.isStrictBindReservedWord = isStrictBindReservedWord;
  9. exports.isKeyword = isKeyword;
  10. const reservedWords = {
  11. keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
  12. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  13. strictBind: ["eval", "arguments"]
  14. };
  15. const keywords = new Set(reservedWords.keyword);
  16. const reservedWordsStrictSet = new Set(reservedWords.strict);
  17. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  18. function isReservedWord(word, inModule) {
  19. return inModule && word === "await" || word === "enum";
  20. }
  21. function isStrictReservedWord(word, inModule) {
  22. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  23. }
  24. function isStrictBindOnlyReservedWord(word) {
  25. return reservedWordsStrictBindSet.has(word);
  26. }
  27. function isStrictBindReservedWord(word, inModule) {
  28. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  29. }
  30. function isKeyword(word) {
  31. return keywords.has(word);
  32. }