Product
Introducing Java Support in Socket
We're excited to announce that Socket now supports the Java programming language.
Node.js Transform stream that passes data through at `n` bytes per second
n
bytes per secondThis module offers a Throttle
passthrough stream class, which allows you to
write data to it and it will be passed through in n
bytes per second. It can
be useful for throttling HTTP uploads or to simulate reading from a file in
real-time, etc.
$ npm install throttle
Here's an example of throttling stdin at 1 byte per second and outputting the data to stdout:
var Throttle = require('throttle');
// create a "Throttle" instance that reads at 1 bps
var throttle = new Throttle(1);
process.stdin.pipe(throttle).pipe(process.stdout);
We can see it in action with the echo
command:
The Throttle
passthrough stream class is very similar to the node core
stream.Passthrough
stream, except that you specify a bps
"bytes per
second" option and data will not be passed through faster than the byte
value you specify.
You can invoke with just a bps
Number and get the rest of the default
options. This should be more common:
process.stdin.pipe(new Throttle(100 * 1024)).pipe(process.stdout);
Or you can pass an options
Object in, with a bps
value specified along with
other options:
var t = new Throttle({ bps: 100 * 1024, chunkSize: 100, highWaterMark: 500 });
FAQs
Node.js Transform stream that passes data through at `n` bytes per second
The npm package throttle receives a total of 3,476 weekly downloads. As such, throttle popularity was classified as popular.
We found that throttle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.
Security News
Deno 2.0 is now available with enhanced package management, full Node.js and npm compatibility, improved performance, and support for major JavaScript frameworks.