Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
CLI-Progress package - How to hide the progress bar on start?

I'm using the CLI-Progress package from:
https://www.npmjs.com/package/cli-progress.

This is my implementation according to the documentation example:
https://github.com/npkgz/cli-progress/blob/master/examples/example-visual.js)

const b1 = new progress.Bar({
    format: colors.cyan('[{bar}]') + ' {percentage}% || {value}/{total} Chunks || Speed: {speed}',
    barCompleteChar: '\u2588',
    barIncompleteChar: '\u2591',
    hideCursor: true,
});

b1.start(200, 0, {
    speed: "N/A"
});

let value = 0;
const speedData: number[] = [];

const timer = setInterval(() => {
    value++;
    speedData.push(Math.random() * 2 + 5);
    const currentSpeedData = speedData.splice(-10);
    b1.update(value, {
        speed: (currentSpeedData.reduce((a, b) => {
            return a + b;
        }, 0) / currentSpeedData.length).toFixed(2) + "Mb/s"
    });

    if (value >= b1.getTotal()) {
        clearInterval(timer);
        b1.stop();
    }
}, 20);

Which renders :

enter image description here

I have two questions about this :

  • Why is there two bars (I would like to get rid of the first one) ?
  • Why does it work since the timer function is never called (it is called recursively but there is no first call) ?

Thank you.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!