Socket
Socket
Sign inDemoInstall

@babel/generator

Package Overview
Dependencies
Maintainers
4
Versions
178
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.17.9 to 7.17.10

75

lib/buffer.js

@@ -7,2 +7,13 @@ "use strict";

exports.default = void 0;
function SourcePos() {
return {
identifierName: undefined,
line: undefined,
column: undefined,
filename: undefined,
force: false
};
}
const SPACES_RE = /^[ \t]+$/;

@@ -20,8 +31,3 @@

};
this._sourcePosition = {
identifierName: null,
line: null,
column: null,
filename: null
};
this._sourcePosition = SourcePos();
this._disallowedPop = null;

@@ -37,25 +43,27 @@ this._map = map;

code: this._buf.trimRight(),
map: null,
rawMappings: map == null ? void 0 : map.getRawMappings()
};
decodedMap: map == null ? void 0 : map.getDecoded(),
if (map) {
Object.defineProperty(result, "map", {
configurable: true,
enumerable: true,
get map() {
return result.map = map ? map.get() : null;
},
get() {
return this.map = map.get();
},
set map(value) {
Object.defineProperty(result, "map", {
value,
writable: true
});
},
set(value) {
Object.defineProperty(this, "map", {
value,
writable: true
});
}
get rawMappings() {
return result.rawMappings = map == null ? void 0 : map.getRawMappings();
},
});
}
set rawMappings(value) {
Object.defineProperty(result, "rawMappings", {
value,
writable: true
});
}
};
return result;

@@ -96,2 +104,6 @@ }

queueIndentation(str) {
this._queue.unshift([str, undefined, undefined, undefined, undefined, false]);
}
_flush() {

@@ -133,3 +145,3 @@ let item;

(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position.line, this._position.column, line, column, identifierName, filename, force);
(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position, line, column, identifierName, filename, force);
}

@@ -218,3 +230,3 @@

if (prop && !loc) return;
this._disallowedPop = this._normalizePosition(prop, loc);
this._disallowedPop = this._normalizePosition(prop, loc, SourcePos(), false);
}

@@ -224,13 +236,2 @@

const pos = loc ? loc[prop] : null;
if (targetObj === undefined) {
targetObj = {
identifierName: null,
line: null,
column: null,
filename: null,
force: false
};
}
const origLine = targetObj.line;

@@ -237,0 +238,0 @@ const origColumn = targetObj.column;

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

if (this._indent && this.endsWith(10) && str.charCodeAt(0) !== 10) {
this._buf.queue(this._getIndent());
this._buf.queueIndentation(this._getIndent());
}

@@ -202,0 +202,0 @@ }

@@ -8,46 +8,44 @@ "use strict";

var _sourceMap = require("source-map");
var _genMapping = require("@jridgewell/gen-mapping");
class SourceMap {
constructor(opts, code) {
this._cachedMap = void 0;
this._code = void 0;
this._opts = void 0;
var _opts$sourceFileName;
this._map = void 0;
this._rawMappings = void 0;
this._lastGenLine = void 0;
this._lastSourceLine = void 0;
this._lastSourceColumn = void 0;
this._cachedMap = null;
this._code = code;
this._opts = opts;
this._rawMappings = [];
}
this._sourceFileName = void 0;
this._lastGenLine = 0;
this._lastSourceLine = 0;
this._lastSourceColumn = 0;
const map = this._map = new _genMapping.GenMapping({
sourceRoot: opts.sourceRoot
});
this._sourceFileName = (_opts$sourceFileName = opts.sourceFileName) == null ? void 0 : _opts$sourceFileName.replace(/\\/g, "/");
this._rawMappings = undefined;
get() {
if (!this._cachedMap) {
const map = this._cachedMap = new _sourceMap.SourceMapGenerator({
sourceRoot: this._opts.sourceRoot
if (typeof code === "string") {
(0, _genMapping.setSourceContent)(map, this._sourceFileName, code);
} else if (typeof code === "object") {
Object.keys(code).forEach(sourceFileName => {
(0, _genMapping.setSourceContent)(map, sourceFileName.replace(/\\/g, "/"), code[sourceFileName]);
});
const code = this._code;
if (typeof code === "string") {
map.setSourceContent(this._opts.sourceFileName.replace(/\\/g, "/"), code);
} else if (typeof code === "object") {
Object.keys(code).forEach(sourceFileName => {
map.setSourceContent(sourceFileName.replace(/\\/g, "/"), code[sourceFileName]);
});
}
this._rawMappings.forEach(mapping => map.addMapping(mapping), map);
}
}
return this._cachedMap.toJSON();
get() {
return (0, _genMapping.encodedMap)(this._map);
}
getDecoded() {
return (0, _genMapping.decodedMap)(this._map);
}
getRawMappings() {
return this._rawMappings.slice();
return this._rawMappings || (this._rawMappings = (0, _genMapping.allMappings)(this._map));
}
mark(generatedLine, generatedColumn, line, column, identifierName, filename, force) {
if (this._lastGenLine !== generatedLine && line === null) return;
mark(generated, line, column, identifierName, filename, force) {
const generatedLine = generated.line;
if (this._lastGenLine !== generatedLine && line == null) return;

@@ -58,14 +56,10 @@ if (!force && this._lastGenLine === generatedLine && this._lastSourceLine === line && this._lastSourceColumn === column) {

this._cachedMap = null;
this._rawMappings = undefined;
this._lastGenLine = generatedLine;
this._lastSourceLine = line;
this._lastSourceColumn = column;
this._rawMappings.push({
name: identifierName || undefined,
generated: {
line: generatedLine,
column: generatedColumn
},
source: line == null ? undefined : (filename || this._opts.sourceFileName).replace(/\\/g, "/"),
(0, _genMapping.addMapping)(this._map, {
name: identifierName,
generated,
source: line == null ? undefined : (filename == null ? void 0 : filename.replace(/\\/g, "/")) || this._sourceFileName,
original: line == null ? undefined : {

@@ -72,0 +66,0 @@ line: line,

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

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

"dependencies": {
"@babel/types": "^7.17.0",
"jsesc": "^2.5.1",
"source-map": "^0.5.0"
"@babel/types": "^7.17.10",
"@jridgewell/gen-mapping": "^0.1.0",
"jsesc": "^2.5.1"
},
"devDependencies": {
"@babel/helper-fixtures": "^7.17.0",
"@babel/parser": "^7.17.9",
"@jridgewell/trace-mapping": "^0.3.4",
"@babel/helper-fixtures": "^7.17.10",
"@babel/parser": "^7.17.10",
"@jridgewell/trace-mapping": "^0.3.8",
"@types/jsesc": "^2.5.0",
"@types/source-map": "^0.5.0",
"charcodes": "^0.2.0"

@@ -34,0 +33,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