Socket
Socket
Sign inDemoInstall

regjsgen

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    regjsgen

Generate regular expressions from regjsparser’s AST.


Version published
Weekly downloads
8.2M
increased by2.51%
Maintainers
1
Install size
14.6 kB
Created
Weekly downloads
 

Package description

What is regjsgen?

The regjsgen package is used to generate regular expressions from parsed structures. It is often used in conjunction with packages like regjsparser, which parses regular expression strings into a structured format that regjsgen can then turn back into regular expression strings. This can be useful for manipulating and generating regular expressions programmatically.

What are regjsgen's main functionalities?

Generate regular expressions from parsed objects

This feature allows you to generate a regular expression string from a parsed regular expression object. The example shows how to generate a simple literal regular expression.

const regjsgen = require('regjsgen');
const parsedRegex = {
  type: 'literal',
  body: 'hello',
  raw: 'hello'
};
const regexString = regjsgen.generate(parsedRegex);
console.log(regexString); // Output: 'hello'

Other packages similar to regjsgen

Readme

Source

regjsgen Build status Code coverage status

Generate regular expressions from regjsparser’s AST.

Installation

npm i regjsgen

API

regjsgen.generate(ast)

This function accepts an abstract syntax tree representing a regular expression (see regjsparser), and returns the generated regular expression string.

const regjsparser = require('regjsparser');
const regjsgen = require('regjsgen');

// Generate an AST with `regjsparser`.
let ast = regjsparser.parse(regex);

// Modify AST
// …

// Generate `RegExp` string with `regjsgen`.
let regex = regjsgen.generate(ast);

Support

Tested on Node.js 16 and 18.
Compatible with regjsparser v0.10.0’s AST.

Keywords

FAQs

Last updated on 06 Jun 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc