Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/regjsgen

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/regjsgen

Generate regular expressions from regjsparser’s AST.

  • 0.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10M
increased by0.53%
Maintainers
4
Weekly downloads
 
Created

What is @babel/regjsgen?

@babel/regjsgen is a utility library that generates regular expressions from abstract syntax trees (ASTs) produced by the @babel/parser. It is particularly useful for transforming and generating regex patterns programmatically.

What are @babel/regjsgen's main functionalities?

Generate Regular Expressions from AST

This feature allows you to generate a regular expression from an abstract syntax tree (AST). The AST can be created manually or obtained from a parser like @babel/parser.

const regjsgen = require('@babel/regjsgen');
const ast = {
  type: 'RegExpLiteral',
  pattern: 'abc',
  flags: ''
};
const regex = regjsgen.generate(ast);
console.log(regex); // Output: /abc/

Support for Complex Patterns

This feature supports generating complex regular expression patterns, including groups, alternations, and quantifiers, from their corresponding AST representations.

const regjsgen = require('@babel/regjsgen');
const ast = {
  type: 'RegExpLiteral',
  pattern: '(a|b)*c',
  flags: 'g'
};
const regex = regjsgen.generate(ast);
console.log(regex); // Output: /(a|b)*c/g

Other packages similar to @babel/regjsgen

Keywords

FAQs

Package last updated on 25 Jan 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc