esutils
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Esutils is a useful package in the ECMAScript utility box, providing a set of tools specifically for the ECMAScript language. Aimed at aiding developers working with ECMAScript, it offers API methods to evaluate whether specific nodes are Expressions, Statements, IterationStatements, and SourceElements as defined by the ECMA262 language specification. It can also help determine if a given character conforms to various syntax rules, such as whether it's a decimal digit, hex digit, octal digit, white space, line terminator, or valid identifier start/part. Furthermore, the esutils package facilitates the identification of keywords, reserved words, and restricted words as per ECMA262 specifications.
Esutils is implemented via the Node.js platform, and it can be integrated into your JavaScript project using a series of API methods as found in the package. Here are a few code examples:
const esutils = require('esutils');
// Use the ast.isStatement function:
let node = { type: 'IfStatement' }; // sample node
let result = esutils.ast.isStatement(node);
console.log(result); // Outputs: true or false
// Use the code.isDecimalDigit function:
let codeVal = 7; // sample decimal code
let isDecimal = esutils.code.isDecimalDigit(codeVal);
console.log(isDecimal); // Outputs: true or false
// Use the keyword.isKeywordES5 function:
let id = 'var'; // sample identifier
let strict = true; // sample strict mode
let isKeyword = esutils.keyword.isKeywordES5(id, strict);
console.log(isKeyword); // Outputs: true or false
These are just a few examples of how you can wield the power of the Esutils utility in your ECMAScript-based project.
The documentation for the esutils package, including a comprehensive list and explanation of its functionalities, can be found within the readme file in its GitHub repository. You'll find code snippets for each of its API methods, providing you with hands-on examples of how to utilize this ECMAScript utility box to the full extent. For a more in-depth understanding of the official ECMAScript specifications the package conforms to, you can find them on the official ECMA262 website at https://es5.github.io and http://ecma-international.org/ecma-262/6.0.