Skip to content

Commit

Permalink
feat: use a shared throttle for bars
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 2, 2018
1 parent 5f03a5a commit 91512c1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/reporters/bars.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { BULLET, TICK } from '../utils/consts';

const globalConsole = console; // eslint-disable-line no-console

const renderT = throttle((fn, ...args) => fn(...args), 1, 50);

export default class BarsReporter {
constructor() {
this.renderT = throttle(this.render.bind(this), 1, 100);
this._render = this._render.bind(this);
this.drafts = null;
}

compiling() {
// eslint-disable-next-line no-console
if (!globalConsole.draft) {
draftLog.into(globalConsole);
}
Expand All @@ -26,14 +27,14 @@ export default class BarsReporter {
}

compiled(context) {
this.render(context);
this._render(context);
}

update(context) {
this.renderT(context);
renderT(this._render, context);
}

render(context) {
_render(context) {
const {
state,
options: { stream, name },
Expand Down

0 comments on commit 91512c1

Please sign in to comment.