stream-valve

1.0.4 • Public • Published

stream-valve Deps Version Version

Ensure that a stream disconnects if it goes over maxBytes perSeconds

Setup

npm install stream-valve

Usage

var valve = require('stream-valve');

socket = net.connect(6379, '127.0.0.1');

socket.on('error', function(err){
    // if valve maximum is reached a ESOCKETOVERFLOW error
    // will be emitted and the socket will be destroyed.
});

// disconnect the socket if it receive more than 1MB per 2 seconds
valve(socket, 1024 * 1024, 2);

socket.on('data', function(){
    // ...
});

Readme

Keywords

none

Package Sidebar

Install

npm i stream-valve

Weekly Downloads

0

Version

1.0.4

License

MIT

Last publish

Collaborators

  • fgribreau