request-progress

Tracks the download progress of a request made with request, giving insight of various metrics including progress percentage, download speed and time remaining.
Installation
$ npm install request-progress
Usage
var fs = require('fs');
var request = require('request');
var progress = require('request-progress');
progress(request('https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE11/Windows/IE11.Win8.1.For.Windows.VirtualBox.zip'), {
})
.on('progress', function (state) {
console.log('progress', state);
})
.on('error', function (err) {
})
.on('end', function () {
})
.pipe(fs.createWriteStream('IE11.Win8.1.For.Windows.VirtualBox.zip'));
If the request's response does not include the content-length
header, the values of some metrics will be null
.
Also speed
and time.remaining
will be null
until it can be calculated.
The state
object emitted in the progress
event is reused to avoid creating a new object for each event.
If you wish to peek the state
object at any time, it is available in request.progressState
.
Tests
$ npm test
$ npm test-cov
to get coverage report
License
Released under the MIT License.