@babel/template
Advanced tools
Comparing version 7.10.4 to 7.12.7
@@ -8,2 +8,8 @@ "use strict"; | ||
var t = _interopRequireWildcard(require("@babel/types")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function makeStatementFormatter(fn) { | ||
@@ -43,16 +49,18 @@ return { | ||
code: str => `(\n${str}\n)`, | ||
validate: ({ | ||
program | ||
}) => { | ||
if (program.body.length > 1) { | ||
validate: ast => { | ||
if (ast.program.body.length > 1) { | ||
throw new Error("Found multiple statements but wanted one"); | ||
} | ||
const expression = program.body[0].expression; | ||
if (expression.start === 0) { | ||
if (expression.unwrap(ast).start === 0) { | ||
throw new Error("Parse result included parens."); | ||
} | ||
}, | ||
unwrap: ast => ast.program.body[0].expression | ||
unwrap: ({ | ||
program | ||
}) => { | ||
const [stmt] = program.body; | ||
t.assertExpressionStatement(stmt); | ||
return stmt.expression; | ||
} | ||
}; | ||
@@ -59,0 +67,0 @@ exports.expression = expression; |
@@ -22,6 +22,6 @@ "use strict"; | ||
return arg => { | ||
const defaultReplacements = arg.reduce((acc, replacement, i) => { | ||
acc[names[i]] = replacement; | ||
return acc; | ||
}, {}); | ||
const defaultReplacements = {}; | ||
arg.forEach((replacement, i) => { | ||
defaultReplacements[names[i]] = replacement; | ||
}); | ||
return arg => { | ||
@@ -28,0 +28,0 @@ const replacements = (0, _options.normalizeReplacements)(arg); |
{ | ||
"name": "@babel/template", | ||
"version": "7.10.4", | ||
"version": "7.12.7", | ||
"description": "Generate an AST from a string template.", | ||
@@ -19,6 +19,5 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"@babel/code-frame": "^7.10.4", | ||
"@babel/parser": "^7.10.4", | ||
"@babel/types": "^7.10.4" | ||
}, | ||
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df" | ||
} | ||
"@babel/parser": "^7.12.7", | ||
"@babel/types": "^7.12.7" | ||
} | ||
} |
@@ -5,3 +5,3 @@ # @babel/template | ||
See our website [@babel/template](https://babeljs.io/docs/en/next/babel-template.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen) associated with this package. | ||
See our website [@babel/template](https://babeljs.io/docs/en/babel-template) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen) associated with this package. | ||
@@ -8,0 +8,0 @@ ## Install |
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
25192
577
Updated@babel/parser@^7.12.7
Updated@babel/types@^7.12.7