JSPM

@putout/operator-regexp

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5111
  • Score
    100M100P100Q137138F
  • License MIT

putout operator adds ability to check if provided regexp can be converted to string without loosing it's sense

Package Exports

  • @putout/operator-regexp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@putout/operator-regexp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@putout/operator-regexp NPM version Dependency Status

putout operator adds ability to determine is provided RegExp can be converted to String without loosing it's sence.

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;

License

MIT