Sha256: 614668cf49b486498c09baeed96d0bad4774687de5501347140d8f90d1b0535c

Contents?: true

Size: 1.41 KB

Versions: 86

Compression:

Stored size: 1.41 KB

Contents

# request-progress [![Build Status](https://secure.travis-ci.org/IndigoUnited/node-request-progress.png)](http://travis-ci.org/IndigoUnited/node-request-progress.png)

Tracks the download progress of a request made with [request](https://github.com/mikeal/request).


## Installation

`$ npm install request-progress`


## Usage

```js
var fs = require('fs');
var request = require('request');
var progress = require('request-progress');

// Note that the options argument is optional
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
})
.on('progress', function (state) {
    console.log('received size in bytes', state.received);
    // The properties bellow can be null if response does not contain
    // the content-length header
    console.log('total size in bytes', state.total);
    console.log('percent', state.percent);
})
.on('error', function (err) {
    // Do something with err
})
.pipe(fs.createWriteStream('doodle.png'))
.on('error', function (err) {
    // Do something with err
})
.on('close', function (err) {
    // Saved to doogle.png!
})
```

Note that the `state` object emitted in the `progress` event is reused to avoid creating a new object for each event.


## License

Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

Version data entries

86 entries across 79 versions & 3 rubygems

Version Path
trusty-festivity-extension-2.5.3 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.5.2 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.5.1 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.5.0 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.4.6 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.4.5 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.4.4 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.4.3 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.4.2 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.4.1 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.4.0 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.30 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.29 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.28 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.27 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.26 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.25 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.24 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.23 node_modules/bower/node_modules/request-progress/README.md
trusty-festivity-extension-2.3.22 node_modules/bower/node_modules/request-progress/README.md