babel-plugin-transform-regexp-constructors
Advanced tools
Comparing version 0.5.0-alpha.b5bafaeb to 0.5.0-alpha.e9f96ffe
"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.b5bafaeb", | ||
"version": "0.5.0-alpha.e9f96ffe", | ||
"description": "This changes RegExp constructors into literals if the RegExp arguments are strings.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
2620
41