stream-valve
v1.0.4
Published
Ensure that a stream disconnects if it goes over `maxBytes` `perSeconds`
Downloads
7
Readme
stream-valve
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(){
// ...
});