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

@babel/generator

Package Overview
Dependencies
Maintainers
6
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.43 to 7.0.0-beta.44

142

lib/buffer.js

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

function _trimRight() {
const data = _interopRequireDefault(require("trim-right"));
var data = _interopRequireDefault(require("trim-right"));
_trimRight = function () {
_trimRight = function _trimRight() {
return data;

@@ -21,6 +21,6 @@ };

const SPACES_RE = /^[ \t]+$/;
var SPACES_RE = /^[ \t]+$/;
class Buffer {
constructor(map) {
var Buffer = function () {
function Buffer(map) {
this._map = null;

@@ -43,7 +43,9 @@ this._buf = [];

get() {
var _proto = Buffer.prototype;
_proto.get = function get() {
this._flush();
const map = this._map;
const result = {
var map = this._map;
var result = {
code: (0, _trimRight().default)(this._buf.join("")),

@@ -58,14 +60,11 @@ map: null,

enumerable: true,
get() {
get: function get() {
return this.map = map.get();
},
set(value) {
set: function set(value) {
Object.defineProperty(this, "map", {
value,
value: value,
writable: true
});
}
});

@@ -75,18 +74,17 @@ }

return result;
}
};
append(str) {
_proto.append = function append(str) {
this._flush();
const {
line,
column,
filename,
identifierName
} = this._sourcePosition;
var _sourcePosition = this._sourcePosition,
line = _sourcePosition.line,
column = _sourcePosition.column,
filename = _sourcePosition.filename,
identifierName = _sourcePosition.identifierName;
this._append(str, line, column, identifierName, filename);
}
};
queue(str) {
_proto.queue = function queue(str) {
if (str === "\n") {

@@ -98,19 +96,20 @@ while (this._queue.length > 0 && SPACES_RE.test(this._queue[0][0])) {

const {
line,
column,
filename,
identifierName
} = this._sourcePosition;
var _sourcePosition2 = this._sourcePosition,
line = _sourcePosition2.line,
column = _sourcePosition2.column,
filename = _sourcePosition2.filename,
identifierName = _sourcePosition2.identifierName;
this._queue.unshift([str, line, column, identifierName, filename]);
}
};
_flush() {
let item;
_proto._flush = function _flush() {
var item;
while (item = this._queue.pop()) this._append(...item);
}
while (item = this._queue.pop()) {
this._append.apply(this, item);
}
};
_append(str, line, column, identifierName, filename) {
_proto._append = function _append(str, line, column, identifierName, filename) {
if (this._map && str[0] !== "\n") {

@@ -124,3 +123,3 @@ this._map.mark(this._position.line, this._position.column, line, column, identifierName, filename);

for (let i = 0; i < str.length; i++) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {

@@ -133,22 +132,22 @@ this._position.line++;

}
}
};
removeTrailingNewline() {
_proto.removeTrailingNewline = function removeTrailingNewline() {
if (this._queue.length > 0 && this._queue[0][0] === "\n") {
this._queue.shift();
}
}
};
removeLastSemicolon() {
_proto.removeLastSemicolon = function removeLastSemicolon() {
if (this._queue.length > 0 && this._queue[0][0] === ";") {
this._queue.shift();
}
}
};
endsWith(suffix) {
_proto.endsWith = function endsWith(suffix) {
if (suffix.length === 1) {
let last;
var last;
if (this._queue.length > 0) {
const str = this._queue[0][0];
var str = this._queue[0][0];
last = str[str.length - 1];

@@ -162,3 +161,5 @@ } else {

const end = this._last + this._queue.reduce((acc, item) => item[0] + acc, "");
var end = this._last + this._queue.reduce(function (acc, item) {
return item[0] + acc;
}, "");

@@ -170,11 +171,11 @@ if (suffix.length <= end.length) {

return false;
}
};
hasContent() {
_proto.hasContent = function hasContent() {
return this._queue.length > 0 || !!this._last;
}
};
source(prop, loc) {
_proto.source = function source(prop, loc) {
if (prop && !loc) return;
const pos = loc ? loc[prop] : null;
var pos = loc ? loc[prop] : null;
this._sourcePosition.identifierName = loc && loc.identifierName || null;

@@ -184,10 +185,10 @@ this._sourcePosition.line = pos ? pos.line : null;

this._sourcePosition.filename = loc && loc.filename || null;
}
};
withSource(prop, loc, cb) {
_proto.withSource = function withSource(prop, loc, cb) {
if (!this._map) return cb();
const originalLine = this._sourcePosition.line;
const originalColumn = this._sourcePosition.column;
const originalFilename = this._sourcePosition.filename;
const originalIdentifierName = this._sourcePosition.identifierName;
var originalLine = this._sourcePosition.line;
var originalColumn = this._sourcePosition.column;
var originalFilename = this._sourcePosition.filename;
var originalIdentifierName = this._sourcePosition.identifierName;
this.source(prop, loc);

@@ -199,17 +200,21 @@ cb();

this._sourcePosition.identifierName = originalIdentifierName;
}
};
getCurrentColumn() {
const extra = this._queue.reduce((acc, item) => item[0] + acc, "");
_proto.getCurrentColumn = function getCurrentColumn() {
var extra = this._queue.reduce(function (acc, item) {
return item[0] + acc;
}, "");
const lastIndex = extra.lastIndexOf("\n");
var lastIndex = extra.lastIndexOf("\n");
return lastIndex === -1 ? this._position.column + extra.length : extra.length - 1 - lastIndex;
}
};
getCurrentLine() {
const extra = this._queue.reduce((acc, item) => item[0] + acc, "");
_proto.getCurrentLine = function getCurrentLine() {
var extra = this._queue.reduce(function (acc, item) {
return item[0] + acc;
}, "");
let count = 0;
var count = 0;
for (let i = 0; i < extra.length; i++) {
for (var i = 0; i < extra.length; i++) {
if (extra[i] === "\n") count++;

@@ -219,6 +224,7 @@ }

return this._position.line + count;
}
};
}
return Buffer;
}();
exports.default = Buffer;

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

enumerable: true,
get: function () {
get: function get() {
return _types.StringLiteral;

@@ -35,3 +35,3 @@ }

this.printInnerComments(node);
const hasDirectives = node.directives && node.directives.length;
var hasDirectives = node.directives && node.directives.length;

@@ -38,0 +38,0 @@ if (node.body.length || hasDirectives) {

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -18,0 +18,0 @@ };

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -138,3 +138,3 @@ };

let computed = node.computed;
var computed = node.computed;

@@ -197,3 +197,3 @@ if (t().isLiteral(node.property) && typeof node.property.value === "number") {

this.space();
const terminatorState = this.startTerminatorless();
var terminatorState = this.startTerminatorless();
this.print(node.argument, node);

@@ -205,5 +205,5 @@ this.endTerminatorless(terminatorState);

const YieldExpression = buildYieldAwait("yield");
var YieldExpression = buildYieldAwait("yield");
exports.YieldExpression = YieldExpression;
const AwaitExpression = buildYieldAwait("await");
var AwaitExpression = buildYieldAwait("await");
exports.AwaitExpression = AwaitExpression;

@@ -231,3 +231,3 @@

function AssignmentExpression(node, parent) {
const parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent);
var parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent);

@@ -268,3 +268,3 @@ if (parens) {

let computed = node.computed;
var computed = node.computed;

@@ -271,0 +271,0 @@ if (t().isLiteral(node.property) && typeof node.property.value === "number") {

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

enumerable: true,
get: function () {
get: function get() {
return _types2.NumericLiteral;

@@ -63,3 +63,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _types2.StringLiteral;

@@ -70,5 +70,5 @@ }

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -228,3 +228,3 @@ };

if (node.declaration) {
const declar = node.declaration;
var declar = node.declaration;
this.print(declar, node);

@@ -454,2 +454,4 @@ if (!t().isStatement(declar)) this.semicolon();

function ObjectTypeAnnotation(node) {
var _this = this;
if (node.exact) {

@@ -461,3 +463,3 @@ this.token("{|");

const props = node.properties.concat(node.callProperties || [], node.indexers || []);
var props = node.properties.concat(node.callProperties || [], node.indexers || []);

@@ -467,12 +469,12 @@ if (props.length) {

this.printJoin(props, node, {
addNewlines(leading) {
addNewlines: function addNewlines(leading) {
if (leading && !props[0]) return 1;
},
indent: true,
statement: true,
iterator: () => {
iterator: function iterator() {
if (props.length !== 1) {
this.token(",");
this.space();
_this.token(",");
_this.space();
}

@@ -479,0 +481,0 @@ }

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

enumerable: true,
get: function () {
get: function get() {
return _templateLiterals[key];

@@ -26,3 +26,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _expressions[key];

@@ -39,3 +39,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _statements[key];

@@ -52,3 +52,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _classes[key];

@@ -65,3 +65,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _methods[key];

@@ -78,3 +78,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _modules[key];

@@ -91,3 +91,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _types[key];

@@ -104,3 +104,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _flow[key];

@@ -117,3 +117,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _base[key];

@@ -130,3 +130,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _jsx[key];

@@ -143,3 +143,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _typescript[key];

@@ -146,0 +146,0 @@ }

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

function JSXText(node) {
const raw = this.getPossibleRaw(node);
var raw = this.getPossibleRaw(node);

@@ -79,8 +79,10 @@ if (raw != null) {

function JSXElement(node) {
const open = node.openingElement;
var open = node.openingElement;
this.print(open, node);
if (open.selfClosing) return;
this.indent();
var _arr = node.children;
for (const child of node.children) {
for (var _i = 0; _i < _arr.length; _i++) {
var child = _arr[_i];
this.print(child, node);

@@ -129,4 +131,6 @@ }

this.indent();
var _arr2 = node.children;
for (const child of node.children) {
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var child = _arr2[_i2];
this.print(child, node);

@@ -133,0 +137,0 @@ }

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -39,3 +39,3 @@ };

function _parameters(parameters, parent) {
for (let i = 0; i < parameters.length; i++) {
for (var i = 0; i < parameters.length; i++) {
this._param(parameters[i], parent);

@@ -58,4 +58,4 @@

function _methodHead(node) {
const kind = node.kind;
const key = node.key;
var kind = node.kind;
var key = node.key;

@@ -136,3 +136,3 @@ if (kind === "get" || kind === "set") {

const firstParam = node.params[0];
var firstParam = node.params[0];

@@ -139,0 +139,0 @@ if (node.params.length === 1 && t().isIdentifier(firstParam) && !hasTypes(node, firstParam)) {

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -114,3 +114,3 @@ };

if (node.declaration) {
const declar = node.declaration;
var declar = node.declaration;
this.print(declar, node);

@@ -124,7 +124,7 @@ if (!t().isStatement(declar)) this.semicolon();

const specifiers = node.specifiers.slice(0);
let hasSpecial = false;
var specifiers = node.specifiers.slice(0);
var hasSpecial = false;
while (true) {
const first = specifiers[0];
var first = specifiers[0];

@@ -176,7 +176,7 @@ if (t().isExportDefaultSpecifier(first) || t().isExportNamespaceSpecifier(first)) {

const specifiers = node.specifiers.slice(0);
var specifiers = node.specifiers.slice(0);
if (specifiers && specifiers.length) {
while (true) {
const first = specifiers[0];
var first = specifiers[0];

@@ -183,0 +183,0 @@ if (t().isImportDefaultSpecifier(first) || t().isImportNamespaceSpecifier(first)) {

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -50,3 +50,3 @@ };

this.space();
const needsBlock = node.alternate && t().isIfStatement(getLastStatement(node.consequent));
var needsBlock = node.alternate && t().isIfStatement(getLastStatement(node.consequent));

@@ -114,3 +114,3 @@ if (needsBlock) {

const buildForXStatement = function (op) {
var buildForXStatement = function buildForXStatement(op) {
return function (node) {

@@ -136,5 +136,5 @@ this.word("for");

const ForInStatement = buildForXStatement("in");
var ForInStatement = buildForXStatement("in");
exports.ForInStatement = ForInStatement;
const ForOfStatement = buildForXStatement("of");
var ForOfStatement = buildForXStatement("of");
exports.ForOfStatement = ForOfStatement;

@@ -155,11 +155,15 @@

function buildLabelStatement(prefix, key = "label") {
function buildLabelStatement(prefix, key) {
if (key === void 0) {
key = "label";
}
return function (node) {
this.word(prefix);
const label = node[key];
var label = node[key];
if (label) {
this.space();
const isLabel = key == "label";
const terminatorState = this.startTerminatorless(isLabel);
var isLabel = key == "label";
var terminatorState = this.startTerminatorless(isLabel);
this.print(label, node);

@@ -173,9 +177,9 @@ this.endTerminatorless(terminatorState);

const ContinueStatement = buildLabelStatement("continue");
var ContinueStatement = buildLabelStatement("continue");
exports.ContinueStatement = ContinueStatement;
const ReturnStatement = buildLabelStatement("return", "argument");
var ReturnStatement = buildLabelStatement("return", "argument");
exports.ReturnStatement = ReturnStatement;
const BreakStatement = buildLabelStatement("break");
var BreakStatement = buildLabelStatement("break");
exports.BreakStatement = BreakStatement;
const ThrowStatement = buildLabelStatement("throw", "argument");
var ThrowStatement = buildLabelStatement("throw", "argument");
exports.ThrowStatement = ThrowStatement;

@@ -234,7 +238,5 @@

indent: true,
addNewlines(leading, cas) {
addNewlines: function addNewlines(leading, cas) {
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
}
});

@@ -271,3 +273,5 @@ this.token("}");

this.newline();
if (this.endsWith("\n")) for (let i = 0; i < 4; i++) this.space(true);
if (this.endsWith("\n")) for (var i = 0; i < 4; i++) {
this.space(true);
}
}

@@ -278,3 +282,5 @@

this.newline();
if (this.endsWith("\n")) for (let i = 0; i < 6; i++) this.space(true);
if (this.endsWith("\n")) for (var i = 0; i < 6; i++) {
this.space(true);
}
}

@@ -290,6 +296,10 @@

this.space();
let hasInits = false;
var hasInits = false;
if (!t().isFor(parent)) {
for (const declar of node.declarations) {
var _arr = node.declarations;
for (var _i = 0; _i < _arr.length; _i++) {
var declar = _arr[_i];
if (declar.init) {

@@ -301,3 +311,3 @@ hasInits = true;

let separator;
var separator;

@@ -309,3 +319,3 @@ if (hasInits) {

this.printList(node.declarations, node, {
separator
separator: separator
});

@@ -312,0 +322,0 @@

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

function TemplateElement(node, parent) {
const isFirst = parent.quasis[0] === node;
const isLast = parent.quasis[parent.quasis.length - 1] === node;
const value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
var isFirst = parent.quasis[0] === node;
var isLast = parent.quasis[parent.quasis.length - 1] === node;
var value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
this.token(value);

@@ -24,5 +24,5 @@ }

function TemplateLiteral(node) {
const quasis = node.quasis;
var quasis = node.quasis;
for (let i = 0; i < quasis.length; i++) {
for (var i = 0; i < quasis.length; i++) {
this.print(quasis[i], node);

@@ -29,0 +29,0 @@

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -30,5 +30,5 @@ };

function _jsesc() {
const data = _interopRequireDefault(require("jsesc"));
var data = _interopRequireDefault(require("jsesc"));
_jsesc = function () {
_jsesc = function _jsesc() {
return data;

@@ -54,3 +54,3 @@ };

function ObjectExpression(node) {
const props = node.properties;
var props = node.properties;
this.token("{");

@@ -106,9 +106,9 @@ this.printInnerComments(node);

function ArrayExpression(node) {
const elems = node.elements;
const len = elems.length;
var elems = node.elements;
var len = elems.length;
this.token("[");
this.printInnerComments(node);
for (let i = 0; i < elems.length; i++) {
const elem = elems[i];
for (var i = 0; i < elems.length; i++) {
var elem = elems[i];

@@ -128,3 +128,3 @@ if (elem) {

function RegExpLiteral(node) {
this.word(`/${node.pattern}/${node.flags}`);
this.word("/" + node.pattern + "/" + node.flags);
}

@@ -141,4 +141,4 @@

function NumericLiteral(node) {
const raw = this.getPossibleRaw(node);
const value = node.value + "";
var raw = this.getPossibleRaw(node);
var value = node.value + "";

@@ -155,3 +155,3 @@ if (raw == null) {

function StringLiteral(node) {
const raw = this.getPossibleRaw(node);
var raw = this.getPossibleRaw(node);

@@ -163,3 +163,3 @@ if (!this.format.minified && raw != null) {

const opts = {
var opts = {
quotes: "double",

@@ -173,4 +173,4 @@ wrap: true

const val = (0, _jsesc().default)(node.value, opts);
var val = (0, _jsesc().default)(node.value, opts);
return this.token(val);
}

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

function TSPropertySignature(node) {
const {
readonly,
initializer
} = node;
var readonly = node.readonly,
initializer = node.initializer;

@@ -194,5 +192,3 @@ if (readonly) {

function TSIndexSignature(node) {
const {
readonly
} = node;
var readonly = node.readonly;

@@ -268,6 +264,4 @@ if (readonly) {

function tsPrintFunctionOrConstructorType(node) {
const {
typeParameters,
parameters
} = node;
var typeParameters = node.typeParameters,
parameters = node.parameters;
this.print(typeParameters, node);

@@ -319,3 +313,15 @@ this.token("(");

for (const member of members) {
for (var _iterator = members, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var member = _ref;
this.print(member, node);

@@ -353,3 +359,3 @@ this.newline();

this.printJoin(node.types, node, {
separator() {
separator: function separator() {
this.space();

@@ -359,3 +365,2 @@ this.token(sep);

}
});

@@ -406,7 +411,5 @@ }

function TSMappedType(node) {
const {
readonly,
typeParameter,
optional
} = node;
var readonly = node.readonly,
typeParameter = node.typeParameter,
optional = node.optional;
this.token("{");

@@ -457,9 +460,7 @@ this.space();

function TSInterfaceDeclaration(node) {
const {
declare,
id,
typeParameters,
extends: extendz,
body
} = node;
var declare = node.declare,
id = node.id,
typeParameters = node.typeParameters,
extendz = node.extends,
body = node.body;

@@ -492,8 +493,6 @@ if (declare) {

function TSTypeAliasDeclaration(node) {
const {
declare,
id,
typeParameters,
typeAnnotation
} = node;
var declare = node.declare,
id = node.id,
typeParameters = node.typeParameters,
typeAnnotation = node.typeAnnotation;

@@ -517,6 +516,4 @@ if (declare) {

function TSAsExpression(node) {
const {
expression,
typeAnnotation
} = node;
var expression = node.expression,
typeAnnotation = node.typeAnnotation;
this.print(expression, node);

@@ -530,6 +527,4 @@ this.space();

function TSTypeAssertion(node) {
const {
typeAnnotation,
expression
} = node;
var typeAnnotation = node.typeAnnotation,
expression = node.expression;
this.token("<");

@@ -543,8 +538,6 @@ this.print(typeAnnotation, node);

function TSEnumDeclaration(node) {
const {
declare,
const: isConst,
id,
members
} = node;
var declare = node.declare,
isConst = node.const,
id = node.id,
members = node.members;

@@ -569,6 +562,4 @@ if (declare) {

function TSEnumMember(node) {
const {
id,
initializer
} = node;
var id = node.id,
initializer = node.initializer;
this.print(id, node);

@@ -587,6 +578,4 @@

function TSModuleDeclaration(node) {
const {
declare,
id
} = node;
var declare = node.declare,
id = node.id;

@@ -610,3 +599,3 @@ if (declare) {

let body = node.body;
var body = node.body;

@@ -628,7 +617,5 @@ while (body.type === "TSModuleDeclaration") {

function TSImportEqualsDeclaration(node) {
const {
isExport,
id,
moduleReference
} = node;
var isExport = node.isExport,
id = node.id,
moduleReference = node.moduleReference;

@@ -681,6 +668,4 @@ if (isExport) {

function tsPrintSignatureDeclarationBase(node) {
const {
typeParameters,
parameters
} = node;
var typeParameters = node.typeParameters,
parameters = node.parameters;
this.print(typeParameters, node);

@@ -687,0 +672,0 @@ this.token("(");

@@ -15,18 +15,32 @@ "use strict";

class Generator extends _printer.default {
constructor(ast, opts = {}, code) {
const format = normalizeOptions(code, opts);
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
super(format, map);
this.ast = ast;
}
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
generate() {
return super.generate(this.ast);
var Generator = function (_Printer) {
_inheritsLoose(Generator, _Printer);
function Generator(ast, opts, code) {
var _this;
if (opts === void 0) {
opts = {};
}
var format = normalizeOptions(code, opts);
var map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
_this = _Printer.call(this, format, map) || this;
_this.ast = ast;
return _this;
}
}
var _proto = Generator.prototype;
_proto.generate = function generate() {
return _Printer.prototype.generate.call(this, this.ast);
};
return Generator;
}(_printer.default);
function normalizeOptions(code, opts) {
const format = {
var format = {
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,

@@ -52,5 +66,9 @@ auxiliaryCommentAfter: opts.auxiliaryCommentAfter,

format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);
format.shouldPrintComment = format.shouldPrintComment || function () {
return format.comments;
};
} else {
format.shouldPrintComment = format.shouldPrintComment || (value => format.comments || value.indexOf("@license") >= 0 || value.indexOf("@preserve") >= 0);
format.shouldPrintComment = format.shouldPrintComment || function (value) {
return format.comments || value.indexOf("@license") >= 0 || value.indexOf("@preserve") >= 0;
};
}

@@ -62,3 +80,3 @@

if (format.compact) {
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + (opts.filename + " as it exceeds the max of " + "500KB" + "."));
}

@@ -74,12 +92,15 @@ }

class CodeGenerator {
constructor(ast, opts, code) {
var CodeGenerator = function () {
function CodeGenerator(ast, opts, code) {
this._generator = new Generator(ast, opts, code);
}
generate() {
var _proto2 = CodeGenerator.prototype;
_proto2.generate = function generate() {
return this._generator.generate();
}
};
}
return CodeGenerator;
}();

@@ -89,4 +110,4 @@ exports.CodeGenerator = CodeGenerator;

function _default(ast, opts, code) {
const gen = new Generator(ast, opts, code);
var gen = new Generator(ast, opts, code);
return gen.generate();
}

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -29,8 +29,8 @@ };

function expandAliases(obj) {
const newObj = {};
var newObj = {};
function add(type, func) {
const fn = newObj[type];
var fn = newObj[type];
newObj[type] = fn ? function (node, parent, stack) {
const result = fn(node, parent, stack);
var result = fn(node, parent, stack);
return result == null ? func(node, parent, stack) : result;

@@ -40,7 +40,22 @@ } : func;

for (const type of Object.keys(obj)) {
const aliases = t().FLIPPED_ALIAS_KEYS[type];
var _arr = Object.keys(obj);
for (var _i = 0; _i < _arr.length; _i++) {
var type = _arr[_i];
var aliases = t().FLIPPED_ALIAS_KEYS[type];
if (aliases) {
for (const alias of aliases) {
for (var _iterator = aliases, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i2 >= _iterator.length) break;
_ref = _iterator[_i2++];
} else {
_i2 = _iterator.next();
if (_i2.done) break;
_ref = _i2.value;
}
var alias = _ref;
add(alias, obj[type]);

@@ -56,8 +71,8 @@ }

const expandedParens = expandAliases(parens);
const expandedWhitespaceNodes = expandAliases(whitespace.nodes);
const expandedWhitespaceList = expandAliases(whitespace.list);
var expandedParens = expandAliases(parens);
var expandedWhitespaceNodes = expandAliases(whitespace.nodes);
var expandedWhitespaceList = expandAliases(whitespace.list);
function find(obj, node, parent, printStack) {
const fn = obj[node.type];
var fn = obj[node.type];
return fn ? fn(node, parent, printStack) : null;

@@ -85,9 +100,9 @@ }

let linesInfo = find(expandedWhitespaceNodes, node, parent);
var linesInfo = find(expandedWhitespaceNodes, node, parent);
if (!linesInfo) {
const items = find(expandedWhitespaceList, node, parent);
var items = find(expandedWhitespaceList, node, parent);
if (items) {
for (let i = 0; i < items.length; i++) {
for (var i = 0; i < items.length; i++) {
linesInfo = needsWhitespace(items[i], node, type);

@@ -94,0 +109,0 @@ if (linesInfo) break;

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -38,3 +38,3 @@ };

const PRECEDENCE = {
var PRECEDENCE = {
"||": 0,

@@ -66,3 +66,5 @@ "&&": 1,

const isClassExtendsClause = (node, parent) => (t().isClassDeclaration(parent) || t().isClassExpression(parent)) && parent.superClass === node;
var isClassExtendsClause = function isClassExtendsClause(node, parent) {
return (t().isClassDeclaration(parent) || t().isClassExpression(parent)) && parent.superClass === node;
};

@@ -109,6 +111,6 @@ function NullableTypeAnnotation(node, parent) {

if (t().isBinary(parent)) {
const parentOp = parent.operator;
const parentPos = PRECEDENCE[parentOp];
const nodeOp = node.operator;
const nodePos = PRECEDENCE[nodeOp];
var parentOp = parent.operator;
var parentPos = PRECEDENCE[parentOp];
var nodeOp = node.operator;
var nodePos = PRECEDENCE[nodeOp];

@@ -194,3 +196,3 @@ if (parentPos === nodePos && parent.right === node && !t().isLogicalExpression(parent) || parentPos > nodePos) {

} else {
return ConditionalExpression(...arguments);
return ConditionalExpression.apply(void 0, arguments);
}

@@ -203,10 +205,13 @@ }

function isFirstInStatement(printStack, {
considerArrow = false,
considerDefaultExports = false
} = {}) {
let i = printStack.length - 1;
let node = printStack[i];
function isFirstInStatement(printStack, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$considerArrow = _ref.considerArrow,
considerArrow = _ref$considerArrow === void 0 ? false : _ref$considerArrow,
_ref$considerDefaultE = _ref.considerDefaultExports,
considerDefaultExports = _ref$considerDefaultE === void 0 ? false : _ref$considerDefaultE;
var i = printStack.length - 1;
var node = printStack[i];
i--;
let parent = printStack[i];
var parent = printStack[i];

@@ -213,0 +218,0 @@ while (i > 0) {

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

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -21,3 +21,7 @@ };

function crawl(node, state = {}) {
function crawl(node, state) {
if (state === void 0) {
state = {};
}
if (t().isMemberExpression(node)) {

@@ -59,5 +63,5 @@ crawl(node.object, state);

const nodes = {
AssignmentExpression(node) {
const state = crawl(node.right);
var nodes = {
AssignmentExpression: function AssignmentExpression(node) {
var state = crawl(node.right);

@@ -71,4 +75,3 @@ if (state.hasCall && state.hasHelper || state.hasFunction) {

},
SwitchCase(node, parent) {
SwitchCase: function SwitchCase(node, parent) {
return {

@@ -79,4 +82,3 @@ before: node.consequent.length || parent.cases[0] === node,

},
LogicalExpression(node) {
LogicalExpression: function LogicalExpression(node) {
if (t().isFunction(node.left) || t().isFunction(node.right)) {

@@ -88,4 +90,3 @@ return {

},
Literal(node) {
Literal: function Literal(node) {
if (node.value === "use strict") {

@@ -97,4 +98,3 @@ return {

},
CallExpression(node) {
CallExpression: function CallExpression(node) {
if (t().isFunction(node.callee) || isHelper(node)) {

@@ -107,10 +107,9 @@ return {

},
VariableDeclaration: function VariableDeclaration(node) {
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
var enabled = isHelper(declar.id) && !isType(declar.init);
VariableDeclaration(node) {
for (let i = 0; i < node.declarations.length; i++) {
const declar = node.declarations[i];
let enabled = isHelper(declar.id) && !isType(declar.init);
if (!enabled) {
const state = crawl(declar.init);
var state = crawl(declar.init);
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;

@@ -127,4 +126,3 @@ }

},
IfStatement(node) {
IfStatement: function IfStatement(node) {
if (t().isBlockStatement(node.consequent)) {

@@ -137,3 +135,2 @@ return {

}
};

@@ -166,18 +163,20 @@ exports.nodes = nodes;

const list = {
VariableDeclaration(node) {
return node.declarations.map(decl => decl.init);
var list = {
VariableDeclaration: function VariableDeclaration(node) {
return node.declarations.map(function (decl) {
return decl.init;
});
},
ArrayExpression(node) {
ArrayExpression: function ArrayExpression(node) {
return node.elements;
},
ObjectExpression(node) {
ObjectExpression: function ObjectExpression(node) {
return node.properties;
}
};
exports.list = list;
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function ([type, amounts]) {
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function (_ref) {
var type = _ref[0],
amounts = _ref[1];
if (typeof amounts === "boolean") {

@@ -184,0 +183,0 @@ amounts = {

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

function _isInteger() {
const data = _interopRequireDefault(require("lodash/isInteger"));
var data = _interopRequireDefault(require("lodash/isInteger"));
_isInteger = function () {
_isInteger = function _isInteger() {
return data;

@@ -20,5 +20,5 @@ };

function _repeat() {
const data = _interopRequireDefault(require("lodash/repeat"));
var data = _interopRequireDefault(require("lodash/repeat"));
_repeat = function () {
_repeat = function _repeat() {
return data;

@@ -35,5 +35,5 @@ };

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -51,8 +51,8 @@ };

const SCIENTIFIC_NOTATION = /e/i;
const ZERO_DECIMAL_INTEGER = /\.0+$/;
const NON_DECIMAL_LITERAL = /^0[box]/;
var SCIENTIFIC_NOTATION = /e/i;
var ZERO_DECIMAL_INTEGER = /\.0+$/;
var NON_DECIMAL_LITERAL = /^0[box]/;
class Printer {
constructor(format, map) {
var Printer = function () {
function Printer(format, map) {
this.inForStatementInitCounter = 0;

@@ -73,3 +73,5 @@ this._printStack = [];

generate(ast) {
var _proto = Printer.prototype;
_proto.generate = function generate(ast) {
this.print(ast);

@@ -80,21 +82,25 @@

return this._buf.get();
}
};
indent() {
_proto.indent = function indent() {
if (this.format.compact || this.format.concise) return;
this._indent++;
}
};
dedent() {
_proto.dedent = function dedent() {
if (this.format.compact || this.format.concise) return;
this._indent--;
}
};
semicolon(force = false) {
_proto.semicolon = function semicolon(force) {
if (force === void 0) {
force = false;
}
this._maybeAddAuxComment();
this._append(";", !force);
}
};
rightBrace() {
_proto.rightBrace = function rightBrace() {
if (this.format.minified) {

@@ -105,5 +111,9 @@ this._buf.removeLastSemicolon();

this.token("}");
}
};
space(force = false) {
_proto.space = function space(force) {
if (force === void 0) {
force = false;
}
if (this.format.compact) return;

@@ -114,5 +124,5 @@

}
}
};
word(str) {
_proto.word = function word(str) {
if (this._endsWithWord || this.endsWith("/") && str.indexOf("/") === 0) {

@@ -127,10 +137,10 @@ this._space();

this._endsWithWord = true;
}
};
number(str) {
_proto.number = function number(str) {
this.word(str);
this._endsWithInteger = (0, _isInteger().default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== ".";
}
};
token(str) {
_proto.token = function token(str) {
if (str === "--" && this.endsWith("!") || str[0] === "+" && this.endsWith("+") || str[0] === "-" && this.endsWith("-") || str[0] === "." && this._endsWithInteger) {

@@ -143,5 +153,5 @@ this._space();

this._append(str);
}
};
newline(i) {
_proto.newline = function newline(i) {
if (this.format.retainLines || this.format.compact) return;

@@ -160,36 +170,40 @@

for (let j = 0; j < i; j++) {
for (var j = 0; j < i; j++) {
this._newline();
}
}
};
endsWith(str) {
_proto.endsWith = function endsWith(str) {
return this._buf.endsWith(str);
}
};
removeTrailingNewline() {
_proto.removeTrailingNewline = function removeTrailingNewline() {
this._buf.removeTrailingNewline();
}
};
source(prop, loc) {
_proto.source = function source(prop, loc) {
this._catchUp(prop, loc);
this._buf.source(prop, loc);
}
};
withSource(prop, loc, cb) {
_proto.withSource = function withSource(prop, loc, cb) {
this._catchUp(prop, loc);
this._buf.withSource(prop, loc, cb);
}
};
_space() {
_proto._space = function _space() {
this._append(" ", true);
}
};
_newline() {
_proto._newline = function _newline() {
this._append("\n", true);
}
};
_append(str, queue = false) {
_proto._append = function _append(str, queue) {
if (queue === void 0) {
queue = false;
}
this._maybeAddParen(str);

@@ -202,20 +216,22 @@

this._endsWithInteger = false;
}
};
_maybeIndent(str) {
_proto._maybeIndent = function _maybeIndent(str) {
if (this._indent && this.endsWith("\n") && str[0] !== "\n") {
this._buf.queue(this._getIndent());
}
}
};
_maybeAddParen(str) {
const parenPushNewlineState = this._parenPushNewlineState;
_proto._maybeAddParen = function _maybeAddParen(str) {
var parenPushNewlineState = this._parenPushNewlineState;
if (!parenPushNewlineState) return;
this._parenPushNewlineState = null;
let i;
var i;
for (i = 0; i < str.length && str[i] === " "; i++) continue;
for (i = 0; i < str.length && str[i] === " "; i++) {
continue;
}
if (i === str.length) return;
const cha = str[i];
var cha = str[i];

@@ -225,3 +241,3 @@ if (cha !== "\n") {

if (i + 1 === str.length) return;
const chaPost = str[i + 1];
var chaPost = str[i + 1];
if (chaPost !== "/" && chaPost !== "*") return;

@@ -233,22 +249,26 @@ }

parenPushNewlineState.printed = true;
}
};
_catchUp(prop, loc) {
_proto._catchUp = function _catchUp(prop, loc) {
if (!this.format.retainLines) return;
const pos = loc ? loc[prop] : null;
var pos = loc ? loc[prop] : null;
if (pos && pos.line !== null) {
const count = pos.line - this._buf.getCurrentLine();
var count = pos.line - this._buf.getCurrentLine();
for (let i = 0; i < count; i++) {
for (var i = 0; i < count; i++) {
this._newline();
}
}
}
};
_getIndent() {
_proto._getIndent = function _getIndent() {
return (0, _repeat().default)(this.format.indent.style, this._indent);
}
};
startTerminatorless(isLabel = false) {
_proto.startTerminatorless = function startTerminatorless(isLabel) {
if (isLabel === void 0) {
isLabel = false;
}
if (isLabel) {

@@ -262,5 +282,5 @@ this._noLineTerminator = true;

}
}
};
endTerminatorless(state) {
_proto.endTerminatorless = function endTerminatorless(state) {
this._noLineTerminator = false;

@@ -273,7 +293,9 @@

}
}
};
print(node, parent) {
_proto.print = function print(node, parent) {
var _this = this;
if (!node) return;
const oldConcise = this.format.concise;
var oldConcise = this.format.concise;

@@ -284,6 +306,6 @@ if (node._compact) {

const printMethod = this[node.type];
var printMethod = this[node.type];
if (!printMethod) {
throw new ReferenceError(`unknown node of type ${JSON.stringify(node.type)} with constructor ${JSON.stringify(node && node.constructor.name)}`);
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
}

@@ -293,3 +315,3 @@

const oldInAux = this._insideAux;
var oldInAux = this._insideAux;
this._insideAux = !node.loc;

@@ -299,3 +321,3 @@

let needsParens = n.needsParens(node, parent, this._printStack);
var needsParens = n.needsParens(node, parent, this._printStack);

@@ -310,5 +332,5 @@ if (this.format.retainFunctionParens && node.type === "FunctionExpression" && node.extra && node.extra.parenthesized) {

const loc = t().isProgram(node) || t().isFile(node) ? null : node.loc;
this.withSource("start", loc, () => {
this[node.type](node, parent);
var loc = t().isProgram(node) || t().isFile(node) ? null : node.loc;
this.withSource("start", loc, function () {
_this[node.type](node, parent);
});

@@ -324,13 +346,13 @@

this._insideAux = oldInAux;
}
};
_maybeAddAuxComment(enteredPositionlessNode) {
_proto._maybeAddAuxComment = function _maybeAddAuxComment(enteredPositionlessNode) {
if (enteredPositionlessNode) this._printAuxBeforeComment();
if (!this._insideAux) this._printAuxAfterComment();
}
};
_printAuxBeforeComment() {
_proto._printAuxBeforeComment = function _printAuxBeforeComment() {
if (this._printAuxAfterOnNextUserNode) return;
this._printAuxAfterOnNextUserNode = true;
const comment = this.format.auxiliaryCommentBefore;
var comment = this.format.auxiliaryCommentBefore;

@@ -343,8 +365,8 @@ if (comment) {

}
}
};
_printAuxAfterComment() {
_proto._printAuxAfterComment = function _printAuxAfterComment() {
if (!this._printAuxAfterOnNextUserNode) return;
this._printAuxAfterOnNextUserNode = false;
const comment = this.format.auxiliaryCommentAfter;
var comment = this.format.auxiliaryCommentAfter;

@@ -357,6 +379,6 @@ if (comment) {

}
}
};
getPossibleRaw(node) {
const extra = node.extra;
_proto.getPossibleRaw = function getPossibleRaw(node) {
var extra = node.extra;

@@ -366,13 +388,17 @@ if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {

}
}
};
printJoin(nodes, parent, opts = {}) {
_proto.printJoin = function printJoin(nodes, parent, opts) {
if (opts === void 0) {
opts = {};
}
if (!nodes || !nodes.length) return;
if (opts.indent) this.indent();
const newlineOpts = {
var newlineOpts = {
addNewlines: opts.addNewlines
};
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (!node) continue;

@@ -394,13 +420,13 @@ if (opts.statement) this._printNewline(true, node, parent, newlineOpts);

if (opts.indent) this.dedent();
}
};
printAndIndentOnComments(node, parent) {
const indent = node.leadingComments && node.leadingComments.length > 0;
_proto.printAndIndentOnComments = function printAndIndentOnComments(node, parent) {
var indent = node.leadingComments && node.leadingComments.length > 0;
if (indent) this.indent();
this.print(node, parent);
if (indent) this.dedent();
}
};
printBlock(parent) {
const node = parent.body;
_proto.printBlock = function printBlock(parent) {
var node = parent.body;

@@ -412,13 +438,17 @@ if (!t().isEmptyStatement(node)) {

this.print(node, parent);
}
};
_printTrailingComments(node, parent) {
_proto._printTrailingComments = function _printTrailingComments(node, parent) {
this._printComments(this._getComments(false, node, parent));
}
};
_printLeadingComments(node, parent) {
_proto._printLeadingComments = function _printLeadingComments(node, parent) {
this._printComments(this._getComments(true, node, parent));
}
};
printInnerComments(node, indent = true) {
_proto.printInnerComments = function printInnerComments(node, indent) {
if (indent === void 0) {
indent = true;
}
if (!node.innerComments || !node.innerComments.length) return;

@@ -430,10 +460,18 @@ if (indent) this.indent();

if (indent) this.dedent();
}
};
printSequence(nodes, parent, opts = {}) {
_proto.printSequence = function printSequence(nodes, parent, opts) {
if (opts === void 0) {
opts = {};
}
opts.statement = true;
return this.printJoin(nodes, parent, opts);
}
};
printList(items, parent, opts = {}) {
_proto.printList = function printList(items, parent, opts) {
if (opts === void 0) {
opts = {};
}
if (opts.separator == null) {

@@ -444,5 +482,5 @@ opts.separator = commaSeparator;

return this.printJoin(items, parent, opts);
}
};
_printNewline(leading, node, parent, opts) {
_proto._printNewline = function _printNewline(leading, node, parent, opts) {
if (this.format.retainLines || this.format.compact) return;

@@ -455,3 +493,3 @@

let lines = 0;
var lines = 0;

@@ -461,3 +499,3 @@ if (this._buf.hasContent()) {

if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
const needs = leading ? n.needsWhitespaceBefore : n.needsWhitespaceAfter;
var needs = leading ? n.needsWhitespaceBefore : n.needsWhitespaceAfter;
if (needs(node, parent)) lines++;

@@ -467,9 +505,11 @@ }

this.newline(lines);
}
};
_getComments(leading, node) {
_proto._getComments = function _getComments(leading, node) {
return node && (leading ? node.leadingComments : node.trailingComments) || [];
}
};
_printComment(comment) {
_proto._printComment = function _printComment(comment) {
var _this2 = this;
if (!this.format.shouldPrintComment(comment.value)) return;

@@ -486,35 +526,49 @@ if (comment.ignore) return;

const isBlockComment = comment.type === "CommentBlock";
var isBlockComment = comment.type === "CommentBlock";
this.newline(this._buf.hasContent() && !this._noLineTerminator && isBlockComment ? 1 : 0);
if (!this.endsWith("[") && !this.endsWith("{")) this.space();
let val = !isBlockComment && !this._noLineTerminator ? `//${comment.value}\n` : `/*${comment.value}*/`;
var val = !isBlockComment && !this._noLineTerminator ? "//" + comment.value + "\n" : "/*" + comment.value + "*/";
if (isBlockComment && this.format.indent.adjustMultilineComment) {
const offset = comment.loc && comment.loc.start.column;
var offset = comment.loc && comment.loc.start.column;
if (offset) {
const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
val = val.replace(newlineRegex, "\n");
}
const indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn());
val = val.replace(/\n(?!$)/g, `\n${(0, _repeat().default)(" ", indentSize)}`);
var indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn());
val = val.replace(/\n(?!$)/g, "\n" + (0, _repeat().default)(" ", indentSize));
}
if (this.endsWith("/")) this._space();
this.withSource("start", comment.loc, () => {
this._append(val);
this.withSource("start", comment.loc, function () {
_this2._append(val);
});
this.newline(isBlockComment && !this._noLineTerminator ? 1 : 0);
}
};
_printComments(comments) {
_proto._printComments = function _printComments(comments) {
if (!comments || !comments.length) return;
for (const comment of comments) {
this._printComment(comment);
for (var _iterator = comments, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var _comment = _ref;
this._printComment(_comment);
}
}
};
}
return Printer;
}();

@@ -521,0 +575,0 @@ exports.default = Printer;

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

function _sourceMap() {
const data = _interopRequireDefault(require("source-map"));
var data = _interopRequireDefault(require("source-map"));
_sourceMap = function () {
_sourceMap = function _sourceMap() {
return data;

@@ -21,4 +21,4 @@ };

class SourceMap {
constructor(opts, code) {
var SourceMap = function () {
function SourceMap(opts, code) {
this._cachedMap = null;

@@ -30,8 +30,10 @@ this._code = code;

get() {
var _proto = SourceMap.prototype;
_proto.get = function get() {
if (!this._cachedMap) {
const map = this._cachedMap = new (_sourceMap().default.SourceMapGenerator)({
var map = this._cachedMap = new (_sourceMap().default.SourceMapGenerator)({
sourceRoot: this._opts.sourceRoot
});
const code = this._code;
var code = this._code;

@@ -41,3 +43,3 @@ if (typeof code === "string") {

} else if (typeof code === "object") {
Object.keys(code).forEach(sourceFileName => {
Object.keys(code).forEach(function (sourceFileName) {
map.setSourceContent(sourceFileName, code[sourceFileName]);

@@ -51,9 +53,9 @@ });

return this._cachedMap.toJSON();
}
};
getRawMappings() {
_proto.getRawMappings = function getRawMappings() {
return this._rawMappings.slice();
}
};
mark(generatedLine, generatedColumn, line, column, identifierName, filename) {
_proto.mark = function mark(generatedLine, generatedColumn, line, column, identifierName, filename) {
if (this._lastGenLine !== generatedLine && line === null) return;

@@ -82,6 +84,7 @@

});
}
};
}
return SourceMap;
}();
exports.default = SourceMap;
{
"name": "@babel/generator",
"version": "7.0.0-beta.43",
"version": "7.0.0-beta.44",
"description": "Turns an AST into code.",

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

"dependencies": {
"@babel/types": "7.0.0-beta.43",
"@babel/types": "7.0.0-beta.44",
"jsesc": "^2.5.1",

@@ -22,5 +22,5 @@ "lodash": "^4.2.0",

"devDependencies": {
"@babel/helper-fixtures": "7.0.0-beta.43",
"babylon": "7.0.0-beta.43"
"@babel/helper-fixtures": "7.0.0-beta.44",
"babylon": "7.0.0-beta.44"
}
}
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