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.
38 lines
1.5 KiB
38 lines
1.5 KiB
"use strict"; |
|
|
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.isKeyword = isKeyword; |
|
exports.isReservedWord = isReservedWord; |
|
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord; |
|
exports.isStrictBindReservedWord = isStrictBindReservedWord; |
|
exports.isStrictReservedWord = isStrictReservedWord; |
|
const reservedWords = { |
|
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"], |
|
strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], |
|
strictBind: ["eval", "arguments"] |
|
}; |
|
const keywords = new Set(reservedWords.keyword); |
|
const reservedWordsStrictSet = new Set(reservedWords.strict); |
|
const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); |
|
|
|
function isReservedWord(word, inModule) { |
|
return inModule && word === "await" || word === "enum"; |
|
} |
|
|
|
function isStrictReservedWord(word, inModule) { |
|
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); |
|
} |
|
|
|
function isStrictBindOnlyReservedWord(word) { |
|
return reservedWordsStrictBindSet.has(word); |
|
} |
|
|
|
function isStrictBindReservedWord(word, inModule) { |
|
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); |
|
} |
|
|
|
function isKeyword(word) { |
|
return keywords.has(word); |
|
} |