node-progress icon indicating copy to clipboard operation
node-progress copied to clipboard

the timer starts only after the first tick

Open manish-alphonso-tv opened this issue 10 years ago • 5 comments

the progress bar does not compute / report the :elapsed correctly.

bar = new progressBar ( ' progress [:bar] :elapsed', total : 10, width : 10, callback : function () { process.exit(0); } );

setInterval( function () { bar.tick(); }. 5000);

will report completion in 45 seconds, as opposed to 50 seconds (10 ticks x 5 seconds).

manish-alphonso-tv avatar Jan 02 '15 13:01 manish-alphonso-tv

+1

scotthovestadt avatar Oct 14 '15 21:10 scotthovestadt

Discovered this as well.

mourner avatar Oct 30 '15 10:10 mourner

+1

jaapaurelio avatar Nov 24 '15 11:11 jaapaurelio

This example code is stating a false.

setInterval purely sets an event to run at the end of the first timer and then reset that event from then on out.

If you want the function to run when the interval is set it must be manually called.

setInterval(
function () { bar.tick(); }.
5000);
bar.tick();

Would be correct.

Without having a time window to scale from how could the elapsed know what ETA window to give?

nullivex avatar Nov 24 '15 20:11 nullivex

Try bar.tick(0) after declaring bar may be useful. And the code can be found here

cupools avatar Sep 24 '16 07:09 cupools