format: prettify entire project
This commit is contained in:
90
node_modules/@babel/generator/lib/buffer.js
generated
vendored
90
node_modules/@babel/generator/lib/buffer.js
generated
vendored
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true,
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
@ -10,7 +10,7 @@ function SourcePos() {
|
||||
identifierName: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined
|
||||
filename: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@ -19,12 +19,12 @@ const SPACES_RE = /^[ \t]+$/;
|
||||
class Buffer {
|
||||
constructor(map) {
|
||||
this._map = null;
|
||||
this._buf = "";
|
||||
this._buf = '';
|
||||
this._last = 0;
|
||||
this._queue = [];
|
||||
this._position = {
|
||||
line: 1,
|
||||
column: 0
|
||||
column: 0,
|
||||
};
|
||||
this._sourcePosition = SourcePos();
|
||||
this._disallowedPop = null;
|
||||
@ -40,27 +40,27 @@ class Buffer {
|
||||
decodedMap: map == null ? void 0 : map.getDecoded(),
|
||||
|
||||
get map() {
|
||||
return result.map = map ? map.get() : null;
|
||||
return (result.map = map ? map.get() : null);
|
||||
},
|
||||
|
||||
set map(value) {
|
||||
Object.defineProperty(result, "map", {
|
||||
Object.defineProperty(result, 'map', {
|
||||
value,
|
||||
writable: true
|
||||
writable: true,
|
||||
});
|
||||
},
|
||||
|
||||
get rawMappings() {
|
||||
return result.rawMappings = map == null ? void 0 : map.getRawMappings();
|
||||
return (result.rawMappings =
|
||||
map == null ? void 0 : map.getRawMappings());
|
||||
},
|
||||
|
||||
set rawMappings(value) {
|
||||
Object.defineProperty(result, "rawMappings", {
|
||||
Object.defineProperty(result, 'rawMappings', {
|
||||
value,
|
||||
writable: true
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
return result;
|
||||
}
|
||||
@ -68,29 +68,19 @@ class Buffer {
|
||||
append(str) {
|
||||
this._flush();
|
||||
|
||||
const {
|
||||
line,
|
||||
column,
|
||||
filename,
|
||||
identifierName
|
||||
} = this._sourcePosition;
|
||||
const { line, column, filename, identifierName } = this._sourcePosition;
|
||||
|
||||
this._append(str, line, column, identifierName, filename);
|
||||
}
|
||||
|
||||
queue(str) {
|
||||
if (str === "\n") {
|
||||
if (str === '\n') {
|
||||
while (this._queue.length > 0 && SPACES_RE.test(this._queue[0][0])) {
|
||||
this._queue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
line,
|
||||
column,
|
||||
filename,
|
||||
identifierName
|
||||
} = this._sourcePosition;
|
||||
const { line, column, filename, identifierName } = this._sourcePosition;
|
||||
|
||||
this._queue.unshift([str, line, column, identifierName, filename]);
|
||||
}
|
||||
@ -102,7 +92,7 @@ class Buffer {
|
||||
_flush() {
|
||||
let item;
|
||||
|
||||
while (item = this._queue.pop()) {
|
||||
while ((item = this._queue.pop())) {
|
||||
this._append(...item);
|
||||
}
|
||||
}
|
||||
@ -110,7 +100,7 @@ class Buffer {
|
||||
_append(str, line, column, identifierName, filename) {
|
||||
this._buf += str;
|
||||
this._last = str.charCodeAt(str.length - 1);
|
||||
let i = str.indexOf("\n");
|
||||
let i = str.indexOf('\n');
|
||||
let last = 0;
|
||||
|
||||
if (i !== 0) {
|
||||
@ -126,7 +116,7 @@ class Buffer {
|
||||
this._mark(++line, 0, identifierName, filename);
|
||||
}
|
||||
|
||||
i = str.indexOf("\n", last);
|
||||
i = str.indexOf('\n', last);
|
||||
}
|
||||
|
||||
this._position.column += str.length - last;
|
||||
@ -135,17 +125,19 @@ class Buffer {
|
||||
_mark(line, column, identifierName, filename) {
|
||||
var _this$_map;
|
||||
|
||||
(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position, line, column, identifierName, filename);
|
||||
(_this$_map = this._map) == null ?
|
||||
void 0
|
||||
: _this$_map.mark(this._position, line, column, identifierName, filename);
|
||||
}
|
||||
|
||||
removeTrailingNewline() {
|
||||
if (this._queue.length > 0 && this._queue[0][0] === "\n") {
|
||||
if (this._queue.length > 0 && this._queue[0][0] === '\n') {
|
||||
this._queue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
removeLastSemicolon() {
|
||||
if (this._queue.length > 0 && this._queue[0][0] === ";") {
|
||||
if (this._queue.length > 0 && this._queue[0][0] === ';') {
|
||||
this._queue.shift();
|
||||
}
|
||||
}
|
||||
@ -185,11 +177,11 @@ class Buffer {
|
||||
}
|
||||
|
||||
exactSource(loc, cb) {
|
||||
this.source("start", loc);
|
||||
this.source('start', loc);
|
||||
cb();
|
||||
this.source("end", loc);
|
||||
this.source('end', loc);
|
||||
|
||||
this._disallowPop("start", loc);
|
||||
this._disallowPop('start', loc);
|
||||
}
|
||||
|
||||
source(prop, loc) {
|
||||
@ -207,7 +199,12 @@ class Buffer {
|
||||
this.source(prop, loc);
|
||||
cb();
|
||||
|
||||
if (!this._disallowedPop || this._disallowedPop.line !== originalLine || this._disallowedPop.column !== originalColumn || this._disallowedPop.filename !== originalFilename) {
|
||||
if (
|
||||
!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;
|
||||
@ -223,7 +220,9 @@ class Buffer {
|
||||
|
||||
_normalizePosition(prop, loc, targetObj) {
|
||||
const pos = loc ? loc[prop] : null;
|
||||
targetObj.identifierName = prop === "start" && (loc == null ? void 0 : loc.identifierName) || undefined;
|
||||
targetObj.identifierName =
|
||||
(prop === 'start' && (loc == null ? void 0 : loc.identifierName)) ||
|
||||
undefined;
|
||||
targetObj.line = pos == null ? void 0 : pos.line;
|
||||
targetObj.column = pos == null ? void 0 : pos.column;
|
||||
targetObj.filename = loc == null ? void 0 : loc.filename;
|
||||
@ -231,24 +230,25 @@ class Buffer {
|
||||
}
|
||||
|
||||
getCurrentColumn() {
|
||||
const extra = this._queue.reduce((acc, item) => item[0] + acc, "");
|
||||
const extra = this._queue.reduce((acc, item) => item[0] + acc, '');
|
||||
|
||||
const lastIndex = extra.lastIndexOf("\n");
|
||||
return lastIndex === -1 ? this._position.column + extra.length : extra.length - 1 - lastIndex;
|
||||
const 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, "");
|
||||
const extra = this._queue.reduce((acc, item) => item[0] + acc, '');
|
||||
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < extra.length; i++) {
|
||||
if (extra[i] === "\n") count++;
|
||||
if (extra[i] === '\n') count++;
|
||||
}
|
||||
|
||||
return this._position.line + count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Buffer;
|
||||
exports.default = Buffer;
|
||||
|
Reference in New Issue
Block a user