keyword.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isKeyword = isKeyword;
  6. exports.isReservedWord = isReservedWord;
  7. exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
  8. exports.isStrictBindReservedWord = isStrictBindReservedWord;
  9. exports.isStrictReservedWord = isStrictReservedWord;
  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. }
  33. //# sourceMappingURL=keyword.js.map