node-throttle

Node.js Transform stream that passes data through at `n` bytes per second

  • Owner: TooTallNate/node-throttle
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

node-throttle

Node.js Transform stream that passes data through at n bytes per second

Build Status

This 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.

Installation

$ npm install throttle

Example

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:

API

Throttle()

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 });

Main metrics

Overview
Name With OwnerTooTallNate/node-throttle
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2011-01-25 02:46:08
Pushed At2017-04-27 17:17:25
Last Commit At2017-04-27 10:17:16
Release Count6
Last Release Namev1.0.3 (Posted on )
First Release Namev0.0.1 (Posted on )
用户参与
Stargazers Count186
Watchers Count8
Fork Count23
Commits Count32
Has Issues Enabled
Issues Count5
Issue Open Count2
Pull Requests Count0
Pull Requests Open Count1
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private