Socket
Socket
Sign inDemoInstall

babel-generator

Package Overview
Dependencies
Maintainers
6
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-generator - npm Package Compare versions

Comparing version 6.23.0 to 6.24.0

6

lib/generators/modules.js

@@ -66,8 +66,2 @@ "use strict";

this.token("*");
if (node.exported) {
this.space();
this.word("as");
this.space();
this.print(node.exported, node);
}
this.space();

@@ -74,0 +68,0 @@ this.word("from");

3

lib/generators/statements.js

@@ -118,3 +118,2 @@ "use strict";

this.space();
op = "of";
}

@@ -125,3 +124,3 @@ this.token("(");

this.space();
this.word(op);
this.word(op === "await" ? "of" : op);
this.space();

@@ -128,0 +127,0 @@ this.print(node.right, node);

@@ -46,7 +46,7 @@ "use strict";

function Generator(ast, opts, code) {
function Generator(ast) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var code = arguments[2];
(0, _classCallCheck3.default)(this, Generator);
opts = opts || {};
var tokens = ast.tokens || [];

@@ -53,0 +53,0 @@ var format = normalizeOptions(code, opts, tokens);

@@ -8,2 +8,3 @@ "use strict";

exports.ObjectExpression = ObjectExpression;
exports.DoExpression = DoExpression;
exports.Binary = Binary;

@@ -59,7 +60,3 @@ exports.BinaryExpression = BinaryExpression;

function UpdateExpression(node, parent) {
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
return false;
return t.isMemberExpression(parent) && parent.object === node;
}

@@ -71,15 +68,11 @@

function DoExpression(node, parent, printStack) {
return isFirstInStatement(printStack);
}
function Binary(node, parent) {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isUnaryLike(parent) || t.isMemberExpression(parent) && parent.object === node || t.isAwaitExpression(parent)) {
return true;
}
if (t.isUnaryLike(parent)) {
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
if (t.isBinary(parent)) {

@@ -92,9 +85,5 @@ var parentOp = parent.operator;

if (parentPos > nodePos) {
if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent) || parentPos > nodePos) {
return true;
}
if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent)) {
return true;
}
}

@@ -106,48 +95,11 @@

function BinaryExpression(node, parent) {
if (node.operator === "in") {
if (t.isVariableDeclarator(parent)) {
return true;
}
if (t.isFor(parent)) {
return true;
}
}
return false;
return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent));
}
function SequenceExpression(node, parent) {
if (t.isForStatement(parent)) {
return false;
}
if (t.isExpressionStatement(parent) && parent.expression === node) {
if (t.isForStatement(parent) || t.isThrowStatement(parent) || t.isReturnStatement(parent) || t.isIfStatement(parent) && parent.test === node || t.isWhileStatement(parent) && parent.test === node || t.isForInStatement(parent) && parent.right === node || t.isSwitchStatement(parent) && parent.discriminant === node || t.isExpressionStatement(parent) && parent.expression === node) {
return false;
}
if (t.isReturnStatement(parent)) {
return false;
}
if (t.isThrowStatement(parent)) {
return false;
}
if (t.isSwitchStatement(parent) && parent.discriminant === node) {
return false;
}
if (t.isWhileStatement(parent) && parent.test === node) {
return false;
}
if (t.isIfStatement(parent) && parent.test === node) {
return false;
}
if (t.isForInStatement(parent) && parent.right === node) {
return false;
}
return true;

@@ -166,11 +118,3 @@ }

function UnaryLike(node, parent) {
if (t.isMemberExpression(parent, { object: node })) {
return true;
}
if (t.isCallExpression(parent, { callee: node }) || t.isNewExpression(parent, { callee: node })) {
return true;
}
return false;
return t.isMemberExpression(parent, { object: node }) || t.isCallExpression(parent, { callee: node }) || t.isNewExpression(parent, { callee: node });
}

@@ -191,18 +135,6 @@

function ConditionalExpression(node, parent) {
if (t.isUnaryLike(parent)) {
if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, { test: node }) || t.isAwaitExpression(parent)) {
return true;
}
if (t.isBinary(parent)) {
return true;
}
if (t.isConditionalExpression(parent, { test: node })) {
return true;
}
if (t.isAwaitExpression(parent)) {
return true;
}
return UnaryLike(node, parent);

@@ -231,18 +163,6 @@ }

while (i > 0) {
if (t.isExpressionStatement(parent, { expression: node })) {
if (t.isExpressionStatement(parent, { expression: node }) || t.isTaggedTemplateExpression(parent) || considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node }) || considerArrow && t.isArrowFunctionExpression(parent, { body: node })) {
return true;
}
if (t.isTaggedTemplateExpression(parent)) {
return true;
}
if (considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node })) {
return true;
}
if (considerArrow && t.isArrowFunctionExpression(parent, { body: node })) {
return true;
}
if (t.isCallExpression(parent, { callee: node }) || t.isSequenceExpression(parent) && parent.expressions[0] === node || t.isMemberExpression(parent, { object: node }) || t.isConditional(parent, { test: node }) || t.isBinary(parent, { left: node }) || t.isAssignmentExpression(parent, { left: node })) {

@@ -249,0 +169,0 @@ node = parent;

@@ -34,22 +34,18 @@ "use strict";

SourceMap.prototype.get = function get() {
var _this = this;
if (!this._cachedMap) {
var map = this._cachedMap = new _sourceMap2.default.SourceMapGenerator({
file: this._opts.sourceMapTarget,
sourceRoot: this._opts.sourceRoot
});
if (!this._cachedMap) {
(function () {
var map = _this._cachedMap = new _sourceMap2.default.SourceMapGenerator({
file: _this._opts.sourceMapTarget,
sourceRoot: _this._opts.sourceRoot
var code = this._code;
if (typeof code === "string") {
map.setSourceContent(this._opts.sourceFileName, code);
} else if ((typeof code === "undefined" ? "undefined" : (0, _typeof3.default)(code)) === "object") {
(0, _keys2.default)(code).forEach(function (sourceFileName) {
map.setSourceContent(sourceFileName, code[sourceFileName]);
});
}
var code = _this._code;
if (typeof code === "string") {
map.setSourceContent(_this._opts.sourceFileName, code);
} else if ((typeof code === "undefined" ? "undefined" : (0, _typeof3.default)(code)) === "object") {
(0, _keys2.default)(code).forEach(function (sourceFileName) {
map.setSourceContent(sourceFileName, code[sourceFileName]);
});
}
_this._rawMappings.forEach(map.addMapping, map);
})();
this._rawMappings.forEach(map.addMapping, map);
}

@@ -56,0 +52,0 @@

{
"name": "babel-generator",
"version": "6.23.0",
"version": "6.24.0",
"description": "Turns an AST into code.",

@@ -5,0 +5,0 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

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