Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda