node-progress
node-progress copied to clipboard
the timer starts only after the first tick
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).
+1
Discovered this as well.
+1
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?
Try bar.tick(0) after declaring bar may be useful. And the code can be found here