You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
RisvanaCybro 0b9b42c6a3 Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
..
test Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
.editorconfig Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
.jshintrc Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
.npmignore Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
.travis.yml Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
LICENSE Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
README.md Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
foo.js Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
index.js Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago
package.json Jan 12 : [ADD] Initial Commit 'website_quotation_template' 1 year ago

README.md

request-progress

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

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');

// The options argument is optional so you can omit it
progress(request('http://google.com/doodle.png'), {
    throttle: 2000,                    // Throttle the progress event to 2000ms, defaults to 1000ms
    delay: 1000,                       // Only start to emit after 1000ms delay, defaults to 0ms
    lengthHeader: 'x-transfer-length'  // Length header to use, defaults to content-length
})
.on('progress', function (state) {
    // The state is an object that looks like this:
    // {
    //     percentage: 0.5,           // Overall percentage (between 0 to 1)
    //     speed: 554732,             // The download speed in bytes/sec
    //     size: {
    //         total: 90044871,       // The total payload size in bytes
    //         transferred: 27610959  // The transferred payload size in bytes
    //     },
    //     time: {
    //         elapsed: 36.235,      // The total elapsed seconds since the start (3 decimals)
    //         remaining: 81.403     // The remaining seconds to finish (3 decimals)
    //     }
    // }
    console.log('progress', state);
})
.on('error', function (err) {
    // Do something with err
})
.pipe(fs.createWriteStream('doodle.png'));

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.