Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/template

Package Overview
Dependencies
Maintainers
5
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/template - npm Package Compare versions

Comparing version 7.6.0 to 7.7.0

4

lib/index.js

@@ -14,4 +14,6 @@ "use strict";

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
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; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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; }
const smart = (0, _builder.default)(formatters.smart);

@@ -18,0 +20,0 @@ exports.smart = smart;

@@ -8,34 +8,12 @@ "use strict";

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var t = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
var _parser = require("@babel/parser");
return data;
}
var _codeFrame = require("@babel/code-frame");
function _parser() {
const data = require("@babel/parser");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
_parser = function () {
return data;
};
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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; }
return data;
}
function _codeFrame() {
const data = require("@babel/code-frame");
_codeFrame = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
const PATTERN = /^[_$A-Z0-9]+$/;

@@ -51,3 +29,3 @@

} = opts;
t().removePropertiesDeep(ast, {
t.removePropertiesDeep(ast, {
preserveComments

@@ -67,3 +45,3 @@ });

};
t().traverse(ast, placeholderVisitorHandler, {
t.traverse(ast, placeholderVisitorHandler, {
syntactic,

@@ -84,3 +62,3 @@ legacy,

if (t().isPlaceholder(node)) {
if (t.isPlaceholder(node)) {
if (state.syntacticPlaceholders === false) {

@@ -94,6 +72,6 @@ throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false.");

return;
} else if (t().isIdentifier(node) || t().isJSXIdentifier(node)) {
} else if (t.isIdentifier(node) || t.isJSXIdentifier(node)) {
name = node.name;
state.isLegacyRef.value = true;
} else if (t().isStringLiteral(node)) {
} else if (t.isStringLiteral(node)) {
name = node.value;

@@ -120,12 +98,12 @@ state.isLegacyRef.value = true;

if (t().isStringLiteral(node) || t().isPlaceholder(node, {
if (t.isStringLiteral(node) || t.isPlaceholder(node, {
expectedNode: "StringLiteral"
})) {
type = "string";
} else if (t().isNewExpression(parent) && key === "arguments" || t().isCallExpression(parent) && key === "arguments" || t().isFunction(parent) && key === "params") {
} else if (t.isNewExpression(parent) && key === "arguments" || t.isCallExpression(parent) && key === "arguments" || t.isFunction(parent) && key === "params") {
type = "param";
} else if (t().isExpressionStatement(parent) && !t().isPlaceholder(node)) {
} else if (t.isExpressionStatement(parent) && !t.isPlaceholder(node)) {
type = "statement";
ancestors = ancestors.slice(0, -1);
} else if (t().isStatement(node) && t().isPlaceholder(node)) {
} else if (t.isStatement(node) && t.isPlaceholder(node)) {
type = "statement";

@@ -186,3 +164,3 @@ } else {

try {
return (0, _parser().parse)(code, parserOpts);
return (0, _parser.parse)(code, parserOpts);
} catch (err) {

@@ -192,3 +170,3 @@ const loc = err.loc;

if (loc) {
err.message += "\n" + (0, _codeFrame().codeFrameColumns)(code, {
err.message += "\n" + (0, _codeFrame.codeFrameColumns)(code, {
start: loc

@@ -195,0 +173,0 @@ });

@@ -8,16 +8,10 @@ "use strict";

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var t = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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 _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function populatePlaceholders(metadata, replacements) {
const ast = t().cloneNode(metadata.ast);
const ast = t.cloneNode(metadata.ast);

@@ -55,5 +49,5 @@ if (replacements) {

if (Array.isArray(replacement)) {
replacement = replacement.map(node => t().cloneNode(node));
replacement = replacement.map(node => t.cloneNode(node));
} else if (typeof replacement === "object") {
replacement = t().cloneNode(replacement);
replacement = t.cloneNode(replacement);
}

@@ -70,6 +64,6 @@ }

if (typeof replacement === "string") {
replacement = t().stringLiteral(replacement);
replacement = t.stringLiteral(replacement);
}
if (!replacement || !t().isStringLiteral(replacement)) {
if (!replacement || !t.isStringLiteral(replacement)) {
throw new Error("Expected string substitution");

@@ -80,9 +74,9 @@ }

if (!replacement) {
replacement = t().emptyStatement();
replacement = t.emptyStatement();
} else if (Array.isArray(replacement)) {
replacement = t().blockStatement(replacement);
replacement = t.blockStatement(replacement);
} else if (typeof replacement === "string") {
replacement = t().expressionStatement(t().identifier(replacement));
} else if (!t().isStatement(replacement)) {
replacement = t().expressionStatement(replacement);
replacement = t.expressionStatement(t.identifier(replacement));
} else if (!t.isStatement(replacement)) {
replacement = t.expressionStatement(replacement);
}

@@ -92,7 +86,7 @@ } else {

if (typeof replacement === "string") {
replacement = t().identifier(replacement);
replacement = t.identifier(replacement);
}
if (!t().isStatement(replacement)) {
replacement = t().expressionStatement(replacement);
if (!t.isStatement(replacement)) {
replacement = t.expressionStatement(replacement);
}

@@ -103,3 +97,3 @@ }

if (typeof replacement === "string") {
replacement = t().identifier(replacement);
replacement = t.identifier(replacement);
}

@@ -110,3 +104,3 @@

if (typeof replacement === "string") {
replacement = t().identifier(replacement);
replacement = t.identifier(replacement);
}

@@ -120,3 +114,3 @@

if (index === undefined) {
t().validate(parent, key, replacement);
t.validate(parent, key, replacement);
parent[key] = replacement;

@@ -138,5 +132,5 @@ } else {

t().validate(parent, key, items);
t.validate(parent, key, items);
parent[key] = items;
}
}
{
"name": "@babel/template",
"version": "7.6.0",
"version": "7.7.0",
"description": "Generate an AST from a string template.",

@@ -15,6 +15,6 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"@babel/code-frame": "^7.0.0",
"@babel/parser": "^7.6.0",
"@babel/types": "^7.6.0"
"@babel/parser": "^7.7.0",
"@babel/types": "^7.7.0"
},
"gitHead": "cbd5a26e57758e3f748174ff84aa570e8780e85d"
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc