🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@eslint-community/regexpp

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslint-community/regexpp

Regular expression parser for ECMAScript.

4.12.1
latest
Version published
Weekly downloads
39M
9.11%
Maintainers
0
Weekly downloads
 
Created

What is @eslint-community/regexpp?

@eslint-community/regexpp is a utility library for parsing, analyzing, and transforming regular expressions. It is particularly useful for developers who need to work with regular expressions in a programmatic way, such as in linting tools, code editors, or other development tools.

What are @eslint-community/regexpp's main functionalities?

Parsing Regular Expressions

This feature allows you to parse a regular expression string into an Abstract Syntax Tree (AST). The AST can then be analyzed or transformed as needed.

const { parseRegExpLiteral } = require('@eslint-community/regexpp');
const ast = parseRegExpLiteral('/abc/');
console.log(JSON.stringify(ast, null, 2));

Validating Regular Expressions

This feature allows you to validate a regular expression string. If the regex is invalid, an error will be thrown, which can be caught and handled.

const { validateRegExpLiteral } = require('@eslint-community/regexpp');
try {
  validateRegExpLiteral('/abc/');
  console.log('Valid regex');
} catch (e) {
  console.error('Invalid regex', e.message);
}

Traversing AST

This feature allows you to traverse the AST of a regular expression. You can define visitor functions that will be called for specific types of nodes in the AST.

const { parseRegExpLiteral, visitRegExpAST } = require('@eslint-community/regexpp');
const ast = parseRegExpLiteral('/abc/');
visitRegExpAST(ast, {
  onCharacterClassEnter(node) {
    console.log('Character class:', node);
  }
});

Other packages similar to @eslint-community/regexpp

FAQs

Package last updated on 28 Oct 2024

Did you know?

Socket

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.

Install

Related posts