Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda