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
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.20.0 to 6.21.0

21

lib/buffer.js

@@ -41,6 +41,23 @@ "use strict";

return {
var map = this._map;
var result = {
code: (0, _trimEnd2.default)(this._buf.join("")),
map: this._map ? this._map.get() : null
map: null,
rawMappings: map && map.getRawMappings()
};
if (map) {
Object.defineProperty(result, "map", {
configurable: true,
enumerable: true,
get: function get() {
return this.map = map.get();
},
set: function set(value) {
Object.defineProperty(this, "map", { value: value, writable: true });
}
});
}
return result;
};

@@ -47,0 +64,0 @@

7

lib/generators/base.js

@@ -34,7 +34,10 @@ "use strict";

this.printInnerComments(node);
if (node.body.length) {
var hasDirectives = node.directives && node.directives.length;
if (node.body.length || hasDirectives) {
this.newline();
this.printSequence(node.directives, node, { indent: true });
if (node.directives && node.directives.length) this.newline();
if (hasDirectives) this.newline();

@@ -41,0 +44,0 @@ this.printSequence(node.body, node, { indent: true });

@@ -181,2 +181,4 @@ "use strict";

this.print(node.left, node);
if (node.left.optional) this.token("?");
this.print(node.left.typeAnnotation, node);
this.space();

@@ -183,0 +185,0 @@ this.token("=");

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

exports.JSXExpressionContainer = JSXExpressionContainer;
exports.JSXSpreadChild = JSXSpreadChild;
exports.JSXText = JSXText;

@@ -61,2 +62,9 @@ exports.JSXElement = JSXElement;

function JSXSpreadChild(node) {
this.token("{");
this.token("...");
this.print(node.expression, node);
this.token("}");
}
function JSXText(node) {

@@ -63,0 +71,0 @@ this.token(node.value);

@@ -25,25 +25,40 @@ "use strict";

function SourceMap(opts, code) {
var _this = this;
(0, _classCallCheck3.default)(this, SourceMap);
this._cachedMap = null;
this._code = code;
this._opts = opts;
this._map = new _sourceMap2.default.SourceMapGenerator({
file: opts.sourceMapTarget,
sourceRoot: opts.sourceRoot
});
this._rawMappings = [];
}
if (typeof code === "string") {
this._map.setSourceContent(opts.sourceFileName, code);
} else if ((typeof code === "undefined" ? "undefined" : (0, _typeof3.default)(code)) === "object") {
(0, _keys2.default)(code).forEach(function (sourceFileName) {
_this._map.setSourceContent(sourceFileName, code[sourceFileName]);
});
SourceMap.prototype.get = function get() {
var _this = this;
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]);
});
}
_this._rawMappings.forEach(map.addMapping, map);
})();
}
}
SourceMap.prototype.get = function get() {
return this._map.toJSON();
return this._cachedMap.toJSON();
};
SourceMap.prototype.getRawMappings = function getRawMappings() {
return this._rawMappings.slice();
};
SourceMap.prototype.mark = function mark(generatedLine, generatedColumn, line, column, identifierName, filename) {

@@ -56,2 +71,3 @@ if (this._lastGenLine !== generatedLine && line === null) return;

this._cachedMap = null;
this._lastGenLine = generatedLine;

@@ -61,4 +77,4 @@ this._lastSourceLine = line;

this._map.addMapping({
name: identifierName,
this._rawMappings.push({
name: identifierName || undefined,
generated: {

@@ -68,4 +84,4 @@ line: generatedLine,

},
source: line == null ? null : filename || this._opts.sourceFileName,
original: line == null ? null : {
source: line == null ? undefined : filename || this._opts.sourceFileName,
original: line == null ? undefined : {
line: line,

@@ -72,0 +88,0 @@ column: column

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

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

"babel-runtime": "^6.20.0",
"babel-types": "^6.20.0",
"babel-types": "^6.21.0",
"detect-indent": "^4.0.0",

@@ -19,0 +19,0 @@ "jsesc": "^1.3.0",

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