Socket
Book a DemoInstallSign in
Socket

@putout/operator-regexp

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/operator-regexp

🐊Putout operator adds ability to check if provided regexp can be converted to string without losing it's sense

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

@putout/operator-regexp NPM version

🐊Putout operator adds ability to determine that provided RegExp can be converted to String without losing it's sense.

It is used for example in regexp/convert-replace-to-relace-all:

-'hello'.replace(/hello/g, 'world');
+'hello'.replaceAll('hello', 'world');

Install

npm i putout @putout/operator-regexp

API

isSimpleRegexp(regexp: RegExp)

const {operator} = require('putout');
const {isSimpleRegExp} = operator;

isSimpleRegExp(/hello world/);
// returns
true;

isSimpleRegExp(/^hello/);
// returns
false;

transformRegExp(regexp: String, plugin: Traverser)

transformRegExp('[aab]', {
    report,
    fix,
    traverse,
});

License

MIT

Keywords

putout

FAQs

Package last updated on 15 Aug 2025

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