Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
reserved-words
Advanced tools
The 'reserved-words' npm package is used to check if a given word is a reserved keyword in JavaScript or other ECMAScript versions. This can be useful for validating identifiers in code generation, linting, or other scenarios where you need to ensure that certain words are not used as variable names or other identifiers.
Check if a word is reserved in a specific ECMAScript version
This feature allows you to check if a given word is a reserved keyword in a specific ECMAScript version. In this example, 'class' is checked against ECMAScript 6 (ES6) and returns true because 'class' is a reserved keyword in ES6.
const reservedWords = require('reserved-words');
const isReserved = reservedWords.check('class', 6); // true for ES6
console.log(isReserved);
Check if a word is reserved in multiple ECMAScript versions
This feature allows you to check if a given word is reserved in multiple ECMAScript versions at once. In this example, 'class' is checked against ES3, ES5, and ES6, and returns true because 'class' is a reserved keyword in ES6.
const reservedWords = require('reserved-words');
const isReserved = reservedWords.check('class', [3, 5, 6]); // true for ES3, ES5, and ES6
console.log(isReserved);
Get a list of reserved words for a specific ECMAScript version
This feature allows you to get a list of all reserved words for a specific ECMAScript version. In this example, it retrieves the list of reserved words for ES6.
const reservedWords = require('reserved-words');
const reservedList = reservedWords.list(6);
console.log(reservedList);
Esprima is a high-performance, standard-compliant ECMAScript parser. It can be used to parse JavaScript code and analyze its syntax, including checking for reserved words. Compared to 'reserved-words', Esprima offers a broader range of functionalities for parsing and analyzing JavaScript code.
Acorn is a small, fast, JavaScript-based ECMAScript parser. It can be used to parse JavaScript code and check for reserved words as part of its syntax analysis. Acorn is similar to Esprima but is designed to be faster and more modular.
Tiny package for detecting reserved words.
Reserved Word
is either a Keyword
, or a Future Reserved Word
, or a Null Literal
, or a Boolean Literal
.
See: ES5 #7.6.1 and
ES6 #11.6.2.
npm install reserved-words
Returns true
if provided identifier string is a Reserved Word
in some ECMAScript dialect (ECMA-262 edition).
If the strict
flag is truthy, this function additionally checks whether
word
is a Keyword or Future Reserved Word under strict mode.
var reserved = require('reserved-words');
reserved.check('volatile', 'es3'); // true
reserved.check('volatile', 'es2015'); // false
reserved.check('yield', 3); // false
reserved.check('yield', 6); // true
Represents ECMA-262 3rd edition.
See section 7.5.1.
Represents ECMA-262 5th edition (ECMAScript 5.1).
Reserved Words are formally defined in ECMA262 sections 7.6.1.1 and 7.6.1.2.
Represents [ECMA-262 6th edition](ECMAScript 2015).
Reserved Words are formally defined in sections 11.6.2.1 and 11.6.2.2.
Licensed under The MIT License
FAQs
ECMAScript reserved words checker
We found that reserved-words demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.