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

@babel/generator

Package Overview
Dependencies
Maintainers
5
Versions
183
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 7.0.0-beta.54 to 7.0.0-beta.55

78

lib/buffer.js

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

};
this._disallowedPop = null;
this._map = map;

@@ -81,6 +82,7 @@ }

filename,
identifierName
identifierName,
force
} = this._sourcePosition;
this._append(str, line, column, identifierName, filename);
this._append(str, line, column, identifierName, filename, force);
}

@@ -99,6 +101,7 @@

filename,
identifierName
identifierName,
force
} = this._sourcePosition;
this._queue.unshift([str, line, column, identifierName, filename]);
this._queue.unshift([str, line, column, identifierName, filename, force]);
}

@@ -112,5 +115,5 @@

_append(str, line, column, identifierName, filename) {
_append(str, line, column, identifierName, filename, force) {
if (this._map && str[0] !== "\n") {
this._map.mark(this._position.line, this._position.column, line, column, identifierName, filename);
this._map.mark(this._position.line, this._position.column, line, column, identifierName, filename, force);
}

@@ -171,9 +174,14 @@

source(prop, loc) {
exactSource(loc, cb) {
this.source("start", loc, true);
cb();
this.source("end", loc);
this._disallowPop("start", loc);
}
source(prop, loc, force) {
if (prop && !loc) return;
const pos = loc ? loc[prop] : null;
this._sourcePosition.identifierName = loc && loc.identifierName || null;
this._sourcePosition.line = pos ? pos.line : null;
this._sourcePosition.column = pos ? pos.column : null;
this._sourcePosition.filename = loc && loc.filename || null;
this._normalizePosition(prop, loc, this._sourcePosition, force);
}

@@ -189,8 +197,46 @@

cb();
this._sourcePosition.line = originalLine;
this._sourcePosition.column = originalColumn;
this._sourcePosition.filename = originalFilename;
this._sourcePosition.identifierName = originalIdentifierName;
if ((!this._sourcePosition.force || this._sourcePosition.line !== originalLine || this._sourcePosition.column !== originalColumn || this._sourcePosition.filename !== originalFilename) && (!this._disallowedPop || this._disallowedPop.line !== originalLine || this._disallowedPop.column !== originalColumn || this._disallowedPop.filename !== originalFilename)) {
this._sourcePosition.line = originalLine;
this._sourcePosition.column = originalColumn;
this._sourcePosition.filename = originalFilename;
this._sourcePosition.identifierName = originalIdentifierName;
this._sourcePosition.force = false;
this._disallowedPop = null;
}
}
_disallowPop(prop, loc) {
if (prop && !loc) return;
this._disallowedPop = this._normalizePosition(prop, loc);
}
_normalizePosition(prop, loc, targetObj, force) {
const pos = loc ? loc[prop] : null;
if (targetObj === undefined) {
targetObj = {
identifierName: null,
line: null,
column: null,
filename: null,
force: false
};
}
const origLine = targetObj.line;
const origColumn = targetObj.column;
const origFilename = targetObj.filename;
targetObj.identifierName = prop === "start" && loc && loc.identifierName || null;
targetObj.line = pos ? pos.line : null;
targetObj.column = pos ? pos.column : null;
targetObj.filename = loc && loc.filename || null;
if (force || targetObj.line !== origLine || targetObj.column !== origColumn || targetObj.filename !== origFilename) {
targetObj.force = force;
}
return targetObj;
}
getCurrentColumn() {

@@ -197,0 +243,0 @@ const extra = this._queue.reduce((acc, item) => item[0] + acc, "");

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

this.print(node.tag, node);
this.print(node.typeParameters, node);
this.print(node.quasi, node);

@@ -14,0 +15,0 @@ }

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

function Identifier(node) {
this.word(node.name);
this.exactSource(node.loc, () => {
this.word(node.name);
});
}

@@ -47,0 +49,0 @@

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

exactSource(loc, cb) {
this._catchUp("start", loc);
this._buf.exactSource(loc, cb);
}
source(prop, loc) {

@@ -165,0 +171,0 @@ this._catchUp(prop, loc);

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

mark(generatedLine, generatedColumn, line, column, identifierName, filename) {
mark(generatedLine, generatedColumn, line, column, identifierName, filename, force) {
if (this._lastGenLine !== generatedLine && line === null) return;
if (this._lastGenLine === generatedLine && this._lastSourceLine === line && this._lastSourceColumn === column) {
if (!force && this._lastGenLine === generatedLine && this._lastSourceLine === line && this._lastSourceColumn === column) {
return;

@@ -59,0 +59,0 @@ }

{
"name": "@babel/generator",
"version": "7.0.0-beta.54",
"version": "7.0.0-beta.55",
"description": "Turns an AST into code.",

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

"dependencies": {
"@babel/types": "7.0.0-beta.54",
"@babel/types": "7.0.0-beta.55",
"jsesc": "^2.5.1",
"lodash": "^4.17.5",
"lodash": "^4.17.10",
"source-map": "^0.5.0",

@@ -22,5 +22,5 @@ "trim-right": "^1.0.1"

"devDependencies": {
"@babel/helper-fixtures": "7.0.0-beta.54",
"@babel/parser": "7.0.0-beta.54"
"@babel/helper-fixtures": "7.0.0-beta.55",
"@babel/parser": "7.0.0-beta.55"
}
}
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