# minipass-flush

> A Minipass stream that calls a flush function before emitting 'end'

Latest version **2.0.1** (published 2026-06-08) · BlueOak-1.0.0 license · 0 weekly downloads

## Install

```sh
npm install minipass-flush
pnpm add minipass-flush
yarn add minipass-flush
bun add minipass-flush
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2026-06-08 |
| First published | 2019-09-15 |
| Weekly downloads | 0 |
| License | BlueOak-1.0.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 \|\| 14 >=14.17 |
| Dependencies | 1 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs |
| Keywords | minipass, flush, stream |

## Links

- npm: https://www.npmjs.com/package/minipass-flush
- Repository: https://github.com/isaacs/minipass-flush
- Homepage: https://github.com/isaacs/minipass-flush#readme
- Issues: https://github.com/isaacs/minipass-flush/issues
- npm.io page: https://npm.io/package/minipass-flush

## Dependencies (1)

- [minipass](https://npm.io/package/minipass.md) ^7.1.3

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2026-06-08
- 1.0.7 (v1-legacy) — 2026-03-26
- 2.0.0 — 2026-03-25
- 1.0.6 — 2026-03-25
- 1.0.5 — 2019-09-30
- 1.0.4 — 2019-09-18
- 1.0.3 — 2019-09-17
- 1.0.2 — 2019-09-16
- 1.0.1 — 2019-09-15
- 1.0.0 — 2019-09-15

## README

# minipass-flush

A Minipass stream that calls a flush function before emitting
'end'.

## USAGE

```ts
import { Flush } from 'minipass-flush'
const f = new Flush<Buffer>({
  flush(cb) {
    // call the cb when done, or return a promise
    // the 'end' event will wait for it, along with
    // close, finish, and prefinish.
    // call the cb with an error, or return a rejecting
    // promise to emit 'error' instead of doing the 'end'
    return rerouteAllEncryptions().then(() => clearAllChannels())
  },
  // all other minipass options accepted as well
})

someDataSource.pipe(f).on('end', () => {
  // proper flushing has been accomplished
})

// Or as a subclass implementing a 'flush' method:
class MyFlush extends Flush {
  flush(cb) {
    // old fashioned callback style!
    rerouteAllEncryptions(er => {
      if (er) return cb(er)
      clearAllChannels(er => {
        if (er) cb(er)
        cb()
      })
    })
  }
}
```

That's about it.

If your `flush` method doesn't have to do anything asynchronous,
then it's better to call the callback right away in this tick,
rather than returning `Promise.resolve()`, so that the `end`
event can happen as soon as possible.

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