Tweak indent string generation slightly to make greggm smile

This commit is contained in:
Dustin Campbell 2016-08-26 10:45:35 -07:00
Родитель 833ea9f5d8
Коммит bac456cbbb
1 изменённых файлов: 2 добавлений и 3 удалений

Просмотреть файл

@ -9,8 +9,8 @@ export class Logger {
private _writer: (message: string) => void; private _writer: (message: string) => void;
private _prefix: string; private _prefix: string;
private _indent: string = ' ';
private _indentLevel: number = 0; private _indentLevel: number = 0;
private _indentSize: number = 4;
private _atLineStart: boolean = false; private _atLineStart: boolean = false;
constructor(writer: (message: string) => void, prefix?: string) { constructor(writer: (message: string) => void, prefix?: string) {
@ -21,8 +21,7 @@ export class Logger {
private _appendCore(message: string): void { private _appendCore(message: string): void {
if (this._atLineStart) { if (this._atLineStart) {
if (this._indentLevel > 0) { if (this._indentLevel > 0) {
const repeatCount = this._indentLevel; const indent = " ".repeat(this._indentLevel * this._indentSize);
const indent = this._indent.repeat(repeatCount);
this._writer(indent); this._writer(indent);
} }