deno-library / progress

ProgressBar in terminal for deno
MIT License
60 stars 9 forks source link

Render upon end #5

Closed Brimstedt closed 3 years ago

Brimstedt commented 4 years ago

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.

fuxingZhang commented 4 years ago

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.

SteelAlloy commented 4 years ago

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