# flush-write-stream

> A write stream constructor that supports a flush function that is called before finish is emitted

Latest version **2.0.0** (published 2019-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install flush-write-stream
pnpm add flush-write-stream
yarn add flush-write-stream
bun add flush-write-stream
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-02-08 |
| First published | 2015-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/flush-write-stream) |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/flush-write-stream
- Repository: https://github.com/mafintosh/flush-write-stream
- Issues: https://github.com/mafintosh/flush-write-stream/issues
- npm.io page: https://npm.io/package/flush-write-stream

## Dependencies (2)

- [inherits](https://npm.io/package/inherits.md) ^2.0.3
- [readable-stream](https://npm.io/package/readable-stream.md) ^3.1.1

## Recent versions

- 2.0.0 (latest) — 2019-02-08
- 1.1.1 — 2019-02-08
- 1.1.0 — 2019-02-04
- 1.0.3 — 2018-03-21
- 1.0.2 — 2016-10-16
- 1.0.1 — 2016-10-16
- 1.0.0 — 2015-11-06

## README

# flush-write-stream

A write stream constructor that supports a flush function that is called before `finish` is emitted

```
npm install flush-write-stream
```

[![build status](http://img.shields.io/travis/mafintosh/flush-write-stream.svg?style=flat)](http://travis-ci.org/mafintosh/flush-write-stream)

## Usage

``` js
var writer = require('flush-write-stream')

var ws = writer(write, flush)

ws.on('finish', function () {
  console.log('finished')
})

ws.write('hello')
ws.write('world')
ws.end()

function write (data, enc, cb) {
  // i am your normal ._write method
  console.log('writing', data.toString())
  cb()
}

function flush (cb) {
  // i am called before finish is emitted
  setTimeout(cb, 1000) // wait 1 sec
}
```

If you run the above it will produce the following output

```
writing hello
writing world
(nothing happens for 1 sec)
finished
```

## API

#### `var ws = writer([options], write, [flush])`

Create a new writable stream. Options are forwarded to the stream constructor.

#### `var ws = writer.obj([options], write, [flush])`

Same as the above except `objectMode` is set to `true` per default.

## License

MIT

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