# stream-valve

> Ensure that a stream disconnects if it goes over `maxBytes` `perSeconds`

Latest version **1.0.4** (published 2015-03-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install stream-valve
pnpm add stream-valve
yarn add stream-valve
bun add stream-valve
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2015-03-29 |
| First published | 2015-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Francois-Guillaume Ribreau |
| Maintainers | fgribreau |

## Links

- npm: https://www.npmjs.com/package/stream-valve
- npm.io page: https://npm.io/package/stream-valve

## Recent versions

- 1.0.4 (latest) — 2015-03-29
- 1.0.3 — 2015-03-28
- 1.0.2 — 2015-03-21
- 1.0.1 — 2015-03-21
- 1.0.0 — 2015-03-21

## README

# stream-valve [![Deps](https://david-dm.org/FGRibreau/stream-valve.png)](https://david-dm.org/FGRibreau/stream-valve) [![Version](http://badge.fury.io/js/stream-valve.png)](https://david-dm.org/FGRibreau/stream-valve)  [![Version](https://travis-ci.org/FGRibreau/stream-valve.svg)](https://travis-ci.org/FGRibreau/stream-valve)

Ensure that a stream disconnects if it goes over `maxBytes` `perSeconds`

# Setup

```
npm install stream-valve
```

# Usage

```javascript
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(){
    // ...
});
```

<p align="center">
<a target="_blank" href="https://play.spotify.com/track/58iP9J86ksOPwbo0pWOafk"><img style="width:100%" src="https://cloud.githubusercontent.com/assets/138050/6766986/282bf3e4-d01d-11e4-9d2f-05cb55d3bdc1.gif"></a>
</p>

---
_Source: https://npm.io/package/stream-valve · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
