node-throttle

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

  • 所有者: TooTallNate/node-throttle
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

主要指标

概览
名称与所有者TooTallNate/node-throttle
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2011-01-25 02:46:08
推送于2017-04-27 17:17:25
最后一次提交2017-04-27 10:17:16
发布数6
最新版本名称v1.0.3 (发布于 )
第一版名称v0.0.1 (发布于 )
用户参与
星数186
关注者数8
派生数23
提交数32
已启用问题?
问题数5
打开的问题数2
拉请求数0
打开的拉请求数1
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?