babel-plugin-transform-regexp-constructors
Advanced tools
Comparing version 0.3.0-alpha.5ee3078e to 0.3.0-alpha.636ae276
"use strict"; | ||
function createRegExpLiteral(args, prettify, t) { | ||
const evaluatedArgs = args.map(a => a.evaluate()); | ||
if (!evaluatedArgs.every(a => a.confident && typeof a.value === "string")) { | ||
var evaluatedArgs = args.map(function (a) { | ||
return a.evaluate(); | ||
}); | ||
if (!evaluatedArgs.every(function (a) { | ||
return a.confident && typeof a.value === "string"; | ||
})) { | ||
return; | ||
} | ||
let pattern = evaluatedArgs.length >= 1 && evaluatedArgs[0].value !== "" ? evaluatedArgs[0].value : "(?:)"; | ||
const flags = evaluatedArgs.length >= 2 ? evaluatedArgs[1].value : ""; | ||
var pattern = evaluatedArgs.length >= 1 && evaluatedArgs[0].value !== "" ? evaluatedArgs[0].value : "(?:)"; | ||
var flags = evaluatedArgs.length >= 2 ? evaluatedArgs[1].value : ""; | ||
@@ -25,3 +29,3 @@ pattern = new RegExp(pattern).source; | ||
} | ||
const regExpLiteral = createRegExpLiteral(path.get("arguments"), true, t); | ||
var regExpLiteral = createRegExpLiteral(path.get("arguments"), true, t); | ||
if (regExpLiteral) { | ||
@@ -32,3 +36,5 @@ path.replaceWith(regExpLiteral); | ||
module.exports = function ({ types: t }) { | ||
module.exports = function (_ref) { | ||
var t = _ref.types; | ||
return { | ||
@@ -35,0 +41,0 @@ name: "transform-regexp-constructors", |
{ | ||
"name": "babel-plugin-transform-regexp-constructors", | ||
"version": "0.3.0-alpha.5ee3078e", | ||
"version": "0.3.0-alpha.636ae276", | ||
"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
2667
42