Socket
Socket
Sign inDemoInstall

@babel/generator

Package Overview
Dependencies
10
Maintainers
4
Versions
170
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.18.2 to 7.18.6

8

lib/buffer.js

@@ -43,3 +43,5 @@ "use strict";

get map() {
return result.map = map ? map.get() : null;
const resultMap = map ? map.get() : null;
result.map = resultMap;
return resultMap;
},

@@ -55,3 +57,5 @@

get rawMappings() {
return result.rawMappings = map == null ? void 0 : map.getRawMappings();
const mappings = map == null ? void 0 : map.getRawMappings();
result.rawMappings = mappings;
return mappings;
},

@@ -58,0 +62,0 @@

@@ -66,3 +66,3 @@ "use strict";

if (!this.format.minified && raw != null) {
if (!this.format.minified && raw !== undefined) {
this.token(raw);

@@ -69,0 +69,0 @@ return;

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

function ClassDeclaration(node, parent) {
if (!this.format.decoratorsBeforeExport || !isExportDefaultDeclaration(parent) && !isExportNamedDeclaration(parent)) {
this.printJoin(node.decorators, node);
{
if (!this.format.decoratorsBeforeExport || !isExportDefaultDeclaration(parent) && !isExportNamedDeclaration(parent)) {
this.printJoin(node.decorators, node);
}
}

@@ -87,3 +89,3 @@

this.source("end", node.key.loc);
this.tsPrintClassMemberModifiers(node, true);
this.tsPrintClassMemberModifiers(node);

@@ -123,3 +125,3 @@ if (node.computed) {

this.source("end", node.key.loc);
this.tsPrintClassMemberModifiers(node, true);
this.tsPrintClassMemberModifiers(node);
this.word("accessor");

@@ -197,3 +199,3 @@ this.printInnerComments(node);

this.source("end", node.key.loc);
this.tsPrintClassMemberModifiers(node, false);
this.tsPrintClassMemberModifiers(node);

@@ -200,0 +202,0 @@ this._methodHead(node);

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

exports.AssignmentPattern = AssignmentPattern;
exports.AwaitExpression = void 0;
exports.AwaitExpression = AwaitExpression;
exports.BindExpression = BindExpression;

@@ -32,3 +32,3 @@ exports.CallExpression = CallExpression;

exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier;
exports.YieldExpression = void 0;
exports.YieldExpression = YieldExpression;

@@ -79,5 +79,3 @@ var _t = require("@babel/types");

} else {
this.startTerminatorless(true);
this.print(node.argument, node);
this.endTerminatorless();
this.printTerminatorless(node.argument, node, true);
this.token(node.operator);

@@ -233,24 +231,24 @@ }

function buildYieldAwait(keyword) {
return function (node) {
this.word(keyword);
function AwaitExpression(node) {
this.word("await");
if (node.delegate) {
this.token("*");
}
if (node.argument) {
this.space();
this.printTerminatorless(node.argument, node, false);
}
}
if (node.argument) {
this.space();
const terminatorState = this.startTerminatorless();
this.print(node.argument, node);
this.endTerminatorless(terminatorState);
}
};
function YieldExpression(node) {
this.word("yield");
if (node.delegate) {
this.token("*");
}
if (node.argument) {
this.space();
this.printTerminatorless(node.argument, node, false);
}
}
const YieldExpression = buildYieldAwait("yield");
exports.YieldExpression = YieldExpression;
const AwaitExpression = buildYieldAwait("await");
exports.AwaitExpression = AwaitExpression;
function EmptyStatement() {

@@ -257,0 +255,0 @@ this.semicolon(true);

@@ -222,10 +222,10 @@ "use strict";

FlowExportDeclaration.apply(this, arguments);
FlowExportDeclaration.call(this, node);
}
function DeclareExportAllDeclaration() {
function DeclareExportAllDeclaration(node) {
this.word("declare");
this.space();
_modules.ExportAllDeclaration.apply(this, arguments);
_modules.ExportAllDeclaration.call(this, node);
}

@@ -232,0 +232,0 @@

@@ -70,3 +70,3 @@ "use strict";

if (raw != null) {
if (raw !== undefined) {
this.token(raw);

@@ -73,0 +73,0 @@ } else {

@@ -45,3 +45,7 @@ "use strict";

this.print(parameter, parent);
if (parameter.optional) this.token("?");
if (parameter.optional) {
this.token("?");
}
this.print(parameter.typeAnnotation, parameter);

@@ -115,3 +119,5 @@ }

this._predicate(node);
if (node.type !== "TSDeclareFunction") {
this._predicate(node);
}
}

@@ -118,0 +124,0 @@

@@ -96,24 +96,10 @@ "use strict";

function ExportNamedDeclaration(node) {
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node);
{
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node);
}
}
this.word("export");
this.space();
ExportDeclaration.apply(this, arguments);
}
function ExportDefaultDeclaration(node) {
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node);
}
this.word("export");
this.space();
this.word("default");
this.space();
ExportDeclaration.apply(this, arguments);
}
function ExportDeclaration(node) {
if (node.declaration) {

@@ -172,2 +158,17 @@ const declar = node.declaration;

function ExportDefaultDeclaration(node) {
{
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node);
}
}
this.word("export");
this.space();
this.word("default");
this.space();
const declar = node.declaration;
this.print(declar, node);
if (!isStatement(declar)) this.semicolon();
}
function ImportDeclaration(node) {

@@ -174,0 +175,0 @@ this.word("import");

@@ -6,5 +6,5 @@ "use strict";

});
exports.BreakStatement = void 0;
exports.BreakStatement = BreakStatement;
exports.CatchClause = CatchClause;
exports.ContinueStatement = void 0;
exports.ContinueStatement = ContinueStatement;
exports.DebuggerStatement = DebuggerStatement;

@@ -16,6 +16,6 @@ exports.DoWhileStatement = DoWhileStatement;

exports.LabeledStatement = LabeledStatement;
exports.ReturnStatement = void 0;
exports.ReturnStatement = ReturnStatement;
exports.SwitchCase = SwitchCase;
exports.SwitchStatement = SwitchStatement;
exports.ThrowStatement = void 0;
exports.ThrowStatement = ThrowStatement;
exports.TryStatement = TryStatement;

@@ -77,4 +77,11 @@ exports.VariableDeclaration = VariableDeclaration;

function getLastStatement(statement) {
if (!isStatement(statement.body)) return statement;
return getLastStatement(statement.body);
const {
body
} = statement;
if (isStatement(body) === false) {
return statement;
}
return getLastStatement(body);
}

@@ -116,26 +123,25 @@

const buildForXStatement = function (op) {
return function (node) {
this.word("for");
function ForXStatement(node) {
this.word("for");
this.space();
const isForOf = node.type === "ForOfStatement";
if (isForOf && node.await) {
this.word("await");
this.space();
}
if (op === "of" && node.await) {
this.word("await");
this.space();
}
this.token("(");
this.print(node.left, node);
this.space();
this.word(isForOf ? "of" : "in");
this.space();
this.print(node.right, node);
this.token(")");
this.printBlock(node);
}
this.token("(");
this.print(node.left, node);
this.space();
this.word(op);
this.space();
this.print(node.right, node);
this.token(")");
this.printBlock(node);
};
};
const ForInStatement = buildForXStatement("in");
const ForInStatement = ForXStatement;
exports.ForInStatement = ForInStatement;
const ForOfStatement = buildForXStatement("of");
const ForOfStatement = ForXStatement;
exports.ForOfStatement = ForOfStatement;

@@ -156,28 +162,31 @@

function buildLabelStatement(prefix, key = "label") {
return function (node) {
this.word(prefix);
const label = node[key];
function printStatementAfterKeyword(printer, node, parent, isLabel) {
if (node) {
printer.space();
printer.printTerminatorless(node, parent, isLabel);
}
if (label) {
this.space();
const isLabel = key == "label";
const terminatorState = this.startTerminatorless(isLabel);
this.print(label, node);
this.endTerminatorless(terminatorState);
}
printer.semicolon();
}
this.semicolon();
};
function BreakStatement(node) {
this.word("break");
printStatementAfterKeyword(this, node.label, node, true);
}
const ContinueStatement = buildLabelStatement("continue");
exports.ContinueStatement = ContinueStatement;
const ReturnStatement = buildLabelStatement("return", "argument");
exports.ReturnStatement = ReturnStatement;
const BreakStatement = buildLabelStatement("break");
exports.BreakStatement = BreakStatement;
const ThrowStatement = buildLabelStatement("throw", "argument");
exports.ThrowStatement = ThrowStatement;
function ContinueStatement(node) {
this.word("continue");
printStatementAfterKeyword(this, node.label, node, true);
}
function ReturnStatement(node) {
this.word("return");
printStatementAfterKeyword(this, node.argument, node, false);
}
function ThrowStatement(node) {
this.word("throw");
printStatementAfterKeyword(this, node.argument, node, false);
}
function LabeledStatement(node) {

@@ -184,0 +193,0 @@ this.print(node.label, node);

@@ -216,3 +216,3 @@ "use strict";

if (!this.format.minified && raw != null) {
if (!this.format.minified && raw !== undefined) {
this.token(raw);

@@ -232,3 +232,3 @@ return;

if (!this.format.minified && raw != null) {
if (!this.format.minified && raw !== undefined) {
this.word(raw);

@@ -244,3 +244,3 @@ return;

if (!this.format.minified && raw != null) {
if (!this.format.minified && raw !== undefined) {
this.word(raw);

@@ -247,0 +247,0 @@ return;

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

exports.TSVoidKeyword = TSVoidKeyword;
exports.tsPrintBraced = tsPrintBraced;
exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers;

@@ -76,3 +75,2 @@ exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType;

exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody;
exports.tsPrintUnionOrIntersectionType = tsPrintUnionOrIntersectionType;

@@ -379,21 +377,21 @@ function TSTypeAnnotation(node) {

function tsPrintTypeLiteralOrInterfaceBody(members, node) {
this.tsPrintBraced(members, node);
tsPrintBraced(this, members, node);
}
function tsPrintBraced(members, node) {
this.token("{");
function tsPrintBraced(printer, members, node) {
printer.token("{");
if (members.length) {
this.indent();
this.newline();
printer.indent();
printer.newline();
for (const member of members) {
this.print(member, node);
this.newline();
printer.print(member, node);
printer.newline();
}
this.dedent();
this.rightBrace();
printer.dedent();
printer.rightBrace();
} else {
this.token("}");
printer.token("}");
}

@@ -432,11 +430,11 @@ }

function TSUnionType(node) {
this.tsPrintUnionOrIntersectionType(node, "|");
tsPrintUnionOrIntersectionType(this, node, "|");
}
function TSIntersectionType(node) {
this.tsPrintUnionOrIntersectionType(node, "&");
tsPrintUnionOrIntersectionType(this, node, "&");
}
function tsPrintUnionOrIntersectionType(node, sep) {
this.printJoin(node.types, node, {
function tsPrintUnionOrIntersectionType(printer, node, sep) {
printer.printJoin(node.types, node, {
separator() {

@@ -660,3 +658,3 @@ this.space();

this.space();
this.tsPrintBraced(members, node);
tsPrintBraced(this, members, node);
}

@@ -717,3 +715,3 @@

function TSModuleBlock(node) {
this.tsPrintBraced(node.body, node);
tsPrintBraced(this, node.body, node);
}

@@ -809,3 +807,5 @@

function tsPrintClassMemberModifiers(node, isField) {
function tsPrintClassMemberModifiers(node) {
const isField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
if (isField && node.declare) {

@@ -812,0 +812,0 @@ this.word("declare");

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

},
decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
jsescOption: Object.assign({

@@ -55,2 +54,3 @@ quotes: "double",

{
format.decoratorsBeforeExport = !!opts.decoratorsBeforeExport;
format.jsonCompatibleStrings = opts.jsonCompatibleStrings;

@@ -57,0 +57,0 @@ }

@@ -69,3 +69,3 @@ "use strict";

function needsWhitespace(node, parent, type) {
if (!node) return 0;
if (!node) return false;

@@ -90,6 +90,6 @@ if (isExpressionStatement(node)) {

if (typeof linesInfo === "object" && linesInfo !== null) {
return linesInfo[type] || 0;
return linesInfo[type] || false;
}
return 0;
return false;
}

@@ -96,0 +96,0 @@

@@ -43,3 +43,3 @@ "use strict";

isCallExpression,
isClassDeclaration,
isClass,
isClassExpression,

@@ -90,2 +90,3 @@ isConditional,

"??": 0,
"|>": 0,
"&&": 1,

@@ -116,3 +117,5 @@ "|": 2,

const isClassExtendsClause = (node, parent) => (isClassDeclaration(parent) || isClassExpression(parent)) && parent.superClass === node;
const isClassExtendsClause = (node, parent) => isClass(parent, {
superClass: node
});

@@ -119,0 +122,0 @@ const hasPostfixPart = (node, parent) => (isMemberExpression(parent) || isOptionalMemberExpression(parent)) && parent.object === node || (isCallExpression(parent) || isOptionalCallExpression(parent) || isNewExpression(parent)) && parent.callee === node || isTaggedTemplateExpression(parent) && parent.tag === node || isTSNonNullExpression(parent);

@@ -202,14 +202,10 @@ "use strict";

[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function ([type, amounts]) {
if (typeof amounts === "boolean") {
amounts = {
after: amounts,
before: amounts
};
}
[type].concat(FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
nodes[type] = function () {
return amounts;
return {
after: amounts,
before: amounts
};
};
});
});

@@ -256,20 +256,19 @@ "use strict";

startTerminatorless(isLabel = false) {
printTerminatorless(node, parent, isLabel) {
if (isLabel) {
this._noLineTerminator = true;
return null;
this.print(node, parent);
this._noLineTerminator = false;
} else {
return this._parenPushNewlineState = {
const terminatorState = {
printed: false
};
}
}
this._parenPushNewlineState = terminatorState;
this.print(node, parent);
endTerminatorless(state) {
this._noLineTerminator = false;
if (state != null && state.printed) {
this.dedent();
this.newline();
this.token(")");
if (terminatorState.printed) {
this.dedent();
this.newline();
this.token(")");
}
}

@@ -276,0 +275,0 @@ }

{
"name": "@babel/generator",
"version": "7.18.2",
"version": "7.18.6",
"description": "Turns an AST into code.",

@@ -22,3 +22,3 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/types": "^7.18.2",
"@babel/types": "^7.18.6",
"@jridgewell/gen-mapping": "^0.3.0",

@@ -28,4 +28,4 @@ "jsesc": "^2.5.1"

"devDependencies": {
"@babel/helper-fixtures": "^7.17.10",
"@babel/parser": "^7.18.0",
"@babel/helper-fixtures": "^7.18.6",
"@babel/parser": "^7.18.6",
"@jridgewell/trace-mapping": "^0.3.8",

@@ -37,3 +37,4 @@ "@types/jsesc": "^2.5.0",

"node": ">=6.9.0"
}
},
"type": "commonjs"
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc