babel-plugin-transform-regexp-constructors
This changes RegExp constructors into literals if the RegExp arguments are strings.
Last updated 7 years ago by boopathi .
MIT · Repository · Bugs · Original npm
$ cnpm install babel-plugin-transform-regexp-constructors 
SYNC missed versions from official npm registry.

babel-plugin-transform-regexp-constructors

This changes RegExp constructors into literals if the RegExp arguments are strings.

Example

In

const foo = 'ab+';
var a = new RegExp(foo+'c', 'i');

Out

const foo = 'ab+';
var a = /ab+c/i;

Installation

npm install babel-plugin-transform-regexp-constructors

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-regexp-constructors"]
}

Via CLI

babel --plugins transform-regexp-constructors script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["transform-regexp-constructors"]
});

Current Tags

  • 0.4.3                                ...           latest (7 years ago)

3 Versions

  • 0.0.3                                ...           9 years ago
  • 0.5.0-alpha.9                                ...           7 years ago
  • 0.4.3                                ...           7 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org