# floody

> combines floods of small stream writes while not delaying or buffering writes when not flooded. buffers only up to configure ammount and only keeps buffer around for at most configured interval.

Latest version **0.1.1** (published 2016-01-15) · BSD license · 0 weekly downloads

## Install

```sh
npm install floody
pnpm add floody
yarn add floody
bun add floody
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-01-15 |
| First published | 2012-09-20 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ryan Day |
| Maintainers | soldair |
| Keywords | stream, write, flood, performance, network, socket |

## Links

- npm: https://www.npmjs.com/package/floody
- Repository: https://github.com/soldair/node-floody
- Homepage: https://github.com/soldair/node-floody#readme
- Issues: https://github.com/soldair/node-floody/issues
- npm.io page: https://npm.io/package/floody

## Dependencies (1)

- [through](https://npm.io/package/through.md) ~2.3.4

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2016-01-15
- 0.0.1 — 2012-09-20
- 0.0.0 — 2012-09-20

## README

[![Build Status](https://secure.travis-ci.org/soldair/node-floody.png)](http://travis-ci.org/soldair/node-floody)

# floody
combines floods of small stream writes while not delaying or buffering writes when not flooded. buffers only up to configured amount and only keeps buffer around for at most configured interval.

## example

```js
var fs = require('fs')
, floody = require('floody')
, ws = fs.createWriteStream('file.txt')
;

var flood = floody(ws);

// imaginary function that produces thousands of lines of data
var thousandsOfLines = getThousandsOfLines();

flood.on('write',function(arrayOfData,bytes){
  // arrayOfData is an array of the data argument to floody.write
  // for all of the writes it combined into one.
});

thousandsOfLines.forEach(function(line){
  process.nextTick(function(){
  	flood.write(format(line),1);
  });
});

// when you are done
flood.stop();

// to get data on flood writes to real writes
console.log(flood.stats)

```

## api

floody(stream,options)
  - stream is an object that hass a write method and calls a callback.
  - options
    - interval the max time to wait with a buffer before writing it
    - maxBufferLen the max size the buffer can reach before being flushed
  - returns new flood object

flood.write (buffer,data)
  - buffer may be a string and it will be written to stream
  - data is anything you want an array of all of the data is passed the the flood.on('write') event handler

flood.stop
  - turns off the interval for floody. at this point the object is done.

flood.on
  - flood emits events
    - write (dataArray,bytes)
      - dataArray is an array of all of the data arguments passed to flood.write
      - bytes is the number of bytes just written
    - end
      - flood has been stopped

## woo hoo!

let me know if you have issues or comments. i hope its useful.

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