Remove removeLast usage.

This commit is contained in:
Logan Smyth 2016-04-26 09:22:27 -07:00
parent 80cd3ca331
commit 578f48134b

View File

@ -103,7 +103,8 @@ export default class Buffer {
*/
rightBrace() {
this.newline(true);
if (!this.endsWith("\n")) this.newline();
if (this.format.minified && !this._lastPrintedIsEmptyStatement) {
this._removeLast(";");
}
@ -212,10 +213,9 @@ export default class Buffer {
/**
* Add a newline (or many newlines), maintaining formatting.
* Strips multiple newlines if removeLast is true.
*/
newline(i?: boolean | number, removeLast?: boolean) {
newline(i?: number) {
if (this.format.retainLines || this.format.compact) return;
if (this.format.concise) {
@ -226,18 +226,12 @@ export default class Buffer {
// never allow more than two lines
if (this.endsWith("\n\n")) return;
if (typeof i === "boolean") removeLast = i;
if (typeof i !== "number") i = 1;
i = Math.min(2, i);
if (this.endsWith("{\n") || this.endsWith(":\n")) i--;
if (i <= 0) return;
// remove the last newline
if (removeLast) {
this.removeLast("\n");
}
this._removeSpacesAfterLastNewline();
for (let j = 0; j < i; j++) {
this.push("\n");