js-keywords
v1.0.1
Published
A utility package that provides an up-to-date list of JavaScript reserved keywords and literals. Useful for code analysis, linters, and educational tools.
Maintainers
Readme
js-keywords
A lightweight utility package that provides an up-to-date list of JavaScript reserved keywords. Useful for code analysis, linters, and educational tools.
Installation
npm install js-keywordsUsage
const { isKeyword, jsKeywords } = require("js-keywords");
// Check if a word is a JavaScript keyword
console.log(isKeyword("class")); // true
console.log(isKeyword("hello")); // false
// print all JavaScript keywords
jsKeywords(); API
isKeyword(word)
Checks if the given string is a valid JavaScript keyword.
Parameters:
word– The word to test (string).
Returns:
trueif it is a keyword, otherwisefalse.
jsKeywords()
Returns an array of all JavaScript reserved keywords and literals.
Returns:
- An array of strings containing all keywords.
✅ Example Output
console.log(isKeyword("function")); // true
console.log(isKeyword("openai")); // false
jsKeywords();
// ["break", "case", "catch", "class", "const", "continue", ...]