Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
request-progress
Advanced tools
Tracks the download progress of a request made with mikeal/request, giving insight of various metrics including progress percent, download speed and time remaining
The request-progress npm package is used to track the progress of HTTP requests made using the request library. It provides a simple way to monitor the progress of file uploads and downloads, giving you real-time feedback on the status of your requests.
Track Download Progress
This feature allows you to track the progress of a file download. The 'progress' event provides real-time updates on the download status, including the percentage completed, speed, and remaining time.
const request = require('request');
const progress = require('request-progress');
progress(request('http://example.com/file.zip'))
.on('progress', function (state) {
console.log('progress', state);
})
.on('error', function (err) {
console.error('error', err);
})
.on('end', function () {
console.log('Download completed');
});
Track Upload Progress
This feature allows you to track the progress of a file upload. The 'progress' event provides real-time updates on the upload status, including the percentage completed, speed, and remaining time.
const fs = require('fs');
const request = require('request');
const progress = require('request-progress');
const fileStream = fs.createReadStream('path/to/file.zip');
progress(request.post('http://example.com/upload', { formData: { file: fileStream } }))
.on('progress', function (state) {
console.log('progress', state);
})
.on('error', function (err) {
console.error('error', err);
})
.on('end', function () {
console.log('Upload completed');
});
The progress-stream package provides a way to monitor the progress of data being streamed. It can be used with any stream, not just HTTP requests, making it more versatile than request-progress. However, it requires more manual setup to integrate with HTTP requests.
The axios-progress-bar package is designed to work with the axios HTTP client. It provides a progress bar for file uploads and downloads, similar to request-progress. It is a good alternative if you are using axios instead of the request library.
Tracks the download progress of a request made with request, giving insight of various metrics including progress percentage, download speed and time remaining.
$ npm install request-progress
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
.
$ npm test
$ npm test-cov
to get coverage report
Released under the MIT License.
FAQs
Tracks the download progress of a request made with mikeal/request, giving insight of various metrics including progress percent, download speed and time remaining
We found that request-progress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.