deno-library / progress

ProgressBar in terminal for deno

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render upon end

Brimstedt opened this issue · comments

I did:

progress = new ProgressBar({
    title: 'Processed', 
    total: e.elements.length
  });

  for(let i = 0; i < e.elements.length; i++) {
    let item = process(e.elements[i], type);
    progress.console(JSON.stringify(item));
    progress.render(i);
  }

Note the render(i) will render 0 to total - 1.
This caused the progress to stop at random intervals although all items were processed.

I would have expected the last output to be "68 / 69" if total was 68. But it would say random numbers.

Changing to progress.render(i+1) caused the correct output.

I realize my code was wrong, but I would have expected progress.end() or progress.console() to "flush" the progressbar.

commented

ProgressBar instance cannot be reused.
If you need more than one, you can create multiple instances.

const progress1 = new ProgressBar();
const progress2 = new ProgressBar();

If you have a good idea, welcome to submit a pull request.

@Brimstedt Can you send a screenshot of the problem? I'm not sure I understand