Read the progress of a stream. Supports speed and eta.
Gets the length of the stream automatically if you're using the request or http module. You can also pass the length on initiation. Progress-stream will also check to see if the stream already has a length property.
npm install progress-stream
Usage
This example copies a large file, and prints out the percentage, speed and remaining every 100ms.
var progress = require('progress-stream');var fs = require('fs');var stat = fs.statSync(filename);var str = progress({ length: stat.size, time: 100 /* ms */});str.on
In test/http.js it's shown how to do it with the http module.
Methods
setLength(newLength)
Sometimes, you don't know how big a stream is right away (e.g. multipart file uploads). You might find out after a few chunks have already passed through the stream, seconds or even minutes later. In this case, you can use the setLength method to recalculate the relevant tracked progress data.
var str = progress({});someFickleStreamInstance.pipe(str).pipe(fs.createWriteStream('test.data'));someFickleStreamInstance.on('conviction', function nowIKnowMyLength (actualLength) { str.setLength(actualLength);});