babel-plugin-transform-regexp-constructors
Advanced tools
Comparing version 0.5.0-alpha.55276695 to 0.5.0-alpha.18dcfe13
"use strict"; | ||
function createRegExpLiteral(args, prettify, t) { | ||
var evaluatedArgs = args.map(function (a) { | ||
return a.evaluate(); | ||
}); | ||
const evaluatedArgs = args.map(a => a.evaluate()); | ||
if (!evaluatedArgs.every(function (a) { | ||
return a.confident && typeof a.value === "string"; | ||
})) { | ||
if (!evaluatedArgs.every(a => a.confident && typeof a.value === "string")) { | ||
return; | ||
} | ||
var pattern = evaluatedArgs.length >= 1 && evaluatedArgs[0].value !== "" ? evaluatedArgs[0].value : "(?:)"; | ||
var flags = evaluatedArgs.length >= 2 ? evaluatedArgs[1].value : ""; | ||
let pattern = evaluatedArgs.length >= 1 && evaluatedArgs[0].value !== "" ? evaluatedArgs[0].value : "(?:)"; | ||
const flags = evaluatedArgs.length >= 2 ? evaluatedArgs[1].value : ""; | ||
pattern = new RegExp(pattern).source; | ||
@@ -33,3 +29,3 @@ | ||
var regExpLiteral = createRegExpLiteral(path.get("arguments"), true, t); | ||
const regExpLiteral = createRegExpLiteral(path.get("arguments"), true, t); | ||
@@ -41,4 +37,5 @@ if (regExpLiteral) { | ||
module.exports = function (_ref) { | ||
var t = _ref.types; | ||
module.exports = function ({ | ||
types: t | ||
}) { | ||
return { | ||
@@ -45,0 +42,0 @@ name: "transform-regexp-constructors", |
{ | ||
"name": "babel-plugin-transform-regexp-constructors", | ||
"version": "0.5.0-alpha.55276695", | ||
"version": "0.5.0-alpha.18dcfe13", | ||
"description": "This changes RegExp constructors into literals if the RegExp arguments are strings.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -24,3 +24,3 @@ # babel-plugin-transform-regexp-constructors | ||
```sh | ||
npm install babel-plugin-transform-regexp-constructors | ||
npm install babel-plugin-transform-regexp-constructors --save-dev | ||
``` | ||
@@ -27,0 +27,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2631
41