Skip to content

Commit

Permalink
chore: use property initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Sep 14, 2020
1 parent a83a831 commit 071ab43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
15 changes: 5 additions & 10 deletions packages/jest-console/src/BufferedConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,19 @@ import type {
} from './types';

export default class BufferedConsole extends Console {
private _buffer: ConsoleBuffer;
private _counters: LogCounters;
private _timers: LogTimers;
private _groupDepth: number;
private _buffer: ConsoleBuffer = [];
private _counters: LogCounters = {};
private _timers: LogTimers = {};
private _groupDepth = 0;

constructor() {
const buffer: ConsoleBuffer = [];
super({
write: (message: string) => {
BufferedConsole.write(buffer, 'log', message, null);
BufferedConsole.write(this._buffer, 'log', message, null);

return true;
},
} as NodeJS.WritableStream);
this._buffer = buffer;
this._counters = {};
this._timers = {};
this._groupDepth = 0;
}

Console: NodeJS.ConsoleConstructor = Console;
Expand Down
9 changes: 3 additions & 6 deletions packages/jest-console/src/CustomConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export default class CustomConsole extends Console {
private _stdout: NodeJS.WriteStream;
private _stderr: NodeJS.WriteStream;
private _formatBuffer: Formatter;
private _counters: LogCounters;
private _timers: LogTimers;
private _groupDepth: number;
private _counters: LogCounters = {};
private _timers: LogTimers = {};
private _groupDepth = 0;

constructor(
stdout: NodeJS.WriteStream,
Expand All @@ -32,9 +32,6 @@ export default class CustomConsole extends Console {
this._stdout = stdout;
this._stderr = stderr;
this._formatBuffer = formatBuffer;
this._counters = {};
this._timers = {};
this._groupDepth = 0;
}

Console: NodeJS.ConsoleConstructor = Console;
Expand Down

0 comments on commit 071ab43

Please sign in to comment.