request-progress

WebJar for request-progress

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

request-progress
Последняя версия

Последняя версия

3.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

request-progress
WebJar for request-progress
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/IndigoUnited/node-request-progress

Скачать request-progress

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/request-progress/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>request-progress</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/request-progress/
implementation 'org.webjars.npm:request-progress:3.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/request-progress/
implementation ("org.webjars.npm:request-progress:3.0.0")
'org.webjars.npm:request-progress:jar:3.0.0'
<dependency org="org.webjars.npm" name="request-progress" rev="3.0.0">
  <artifact name="request-progress" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='request-progress', version='3.0.0')
)
libraryDependencies += "org.webjars.npm" % "request-progress" % "3.0.0"
[org.webjars.npm/request-progress "3.0.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm : throttleit jar [1.0.0,2)

Модули Проекта

Данный проект не имеет модулей.

request-progress

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

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('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.

org.webjars.npm

Indigo United

Open-source community

Версии библиотеки

Версия
3.0.0
2.0.1
0.3.1