-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting curr
property breaks :eta
and :rate
#159
Comments
Experiencing this as well. Workaround is not setting |
The problem is that the library doesn't record the download start time when you specify WorkaroundThe most basic workaround is to set the ProgressBar instance's Here's a workaround using custom tokens const lastDownloadSize = startingFileDiskSize;
bar = new ProgressBar(` [:bar] :myRateKB KiBps :percent :myETAs remaining`, {
width: 40,
curr: startingFileDiskSize,
total: remoteSize
});
// Just setting `bar.start` will make :rate and :eta work, but will act like
// the first `curr` bytes were transferred in zero time at infinite rate.
bar.start = Date.now();
downit(url, outPath, {
onprogress: gotBytes => {
const elapsedSecs = (Date.now() - bar.start) / 1000;
const sessionTotalSize = remoteSize - startingFileDiskSize;
const sessionProgress = gotBytes - startingFileDiskSize;
bar.tick(gotBytes - lastDownloadSize, {
myRateKB: Math.round((sessionProgress / 1024) / elapsedSecs),
myETA: Math.round(elapsedSecs * (sessionTotalSize / sessionProgress - 1))
});
lastDownloadSize = got;
}
}); |
Setting `curr` property breaks `:eta`, `:rate`, `:elapsed`. For example, the input `curr` value is 2, but the output `:eta`, `:rate`, `:elapsed` values respectively are 0.0, NaN, 0.0. Current required nature number and is less than or equal to total. Closes visionmedia#159
Setting the
curr
property breaks the:eta
and:rate
tokens.To reproduce, edit
examples/customtokens.js
to include thecurr
property::eta
is always0.0
and:rate
isNaN
The bug isn't present when
curr: 0
The text was updated successfully, but these errors were encountered: