# request-progress

> Tracks the download progress of a request made with mikeal/request, giving insight of various metrics including progress percent, download speed and time remaining

Latest version **3.0.0** (published 2016-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install request-progress
pnpm add request-progress
yarn add request-progress
bun add request-progress
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2016-12-01 |
| First published | 2013-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 217 |
| Author | IndigoUnited |
| Maintainers | satazor |
| Keywords | progress, request, mikeal, size, bytes, percent, percentage, speed, eta, etr |

## Links

- npm: https://www.npmjs.com/package/request-progress
- Repository: https://github.com/IndigoUnited/node-request-progress
- Homepage: https://github.com/IndigoUnited/node-request-progress#readme
- Issues: http://github.com/IndigoUnited/node-request-progress/issues
- npm.io page: https://npm.io/package/request-progress

## Dependencies (1)

- [throttleit](https://npm.io/package/throttleit.md) ^1.0.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2016-12-01
- 2.0.1 — 2016-01-20
- 2.0.0 — 2016-01-20
- 1.0.2 — 2016-01-04
- 1.0.1 — 2016-01-04
- 1.0.0 — 2016-01-04
- 0.4.0 — 2015-11-29
- 0.3.1 — 2013-08-28
- 0.3.0 — 2013-08-28
- 0.2.3 — 2013-08-01
- 0.2.2 — 2013-08-01
- 0.2.1 — 2013-07-14
- 0.2.0 — 2013-07-14
- 0.1.1 — 2013-07-14
- 0.1.0 — 2013-07-14

## README

# request-progress

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]

[npm-url]:https://npmjs.org/package/request-progress
[downloads-image]:http://img.shields.io/npm/dm/request-progress.svg
[npm-image]:http://img.shields.io/npm/v/request-progress.svg
[travis-url]:https://travis-ci.org/IndigoUnited/node-request-progress
[travis-image]:http://img.shields.io/travis/IndigoUnited/node-request-progress/master.svg
[coveralls-url]:https://coveralls.io/r/IndigoUnited/node-request-progress
[coveralls-image]:https://img.shields.io/coveralls/IndigoUnited/node-request-progress/master.svg
[david-dm-url]:https://david-dm.org/IndigoUnited/node-request-progress
[david-dm-image]:https://img.shields.io/david/IndigoUnited/node-request-progress.svg
[david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-request-progress#info=devDependencies
[david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-request-progress.svg

Tracks the download progress of a request made with [request](https://github.com/mikeal/request), giving insight of various metrics including progress percentage, download speed and time remaining.


## Installation

`$ npm install request-progress`


## Usage

```js
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('https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE11/Windows/IE11.Win8.1.For.Windows.VirtualBox.zip'), {
    // 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:
    // {
    //     percent: 0.5,               // Overall percent (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
})
.on('end', function () {
    // Do something after request finishes
})
.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](http://www.opensource.org/licenses/mit-license.php).

---
_Source: https://npm.io/package/request-progress · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
