# minipass-sized

> A Minipass stream that raises an error if you get a different number of bytes than expected

Latest version **2.0.0** (published 2026-01-07) · ISC license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-01-07 |
| First published | 2019-09-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 22 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs |
| Keywords | minipass, size, length |

## Links

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

## Dependencies (1)

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

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2026-01-07
- 1.0.3 — 2019-09-30
- 1.0.2 — 2019-09-21
- 1.0.1 — 2019-09-21
- 1.0.0 — 2019-09-21

## README

# minipass-sized

A Minipass stream that raises an error if you get a different
number of bytes than expected.

## USAGE

Use just like any old [minipass](http://npm.im/minipass) stream,
but provide a `size` option to the constructor.

The `size` option must be a positive integer, smaller than
`Number.MAX_SAFE_INTEGER`.

```ts
import { MinipassSized } from 'minipass-sized'
// or:
// const { MinipassSized } = require('minipass-sized')
// figure out how much data you expect to get
const expectedSize = +headers['content-length']
const stream = new MinipassSized({ size: expectedSize })
stream.on('error', er => {
  // if it's the wrong size, then this will raise an error with
  // { found: <number>, expect: <number>, code: 'EBADSIZE' }
})
response.pipe(stream)
```

Caveats: this does not work with `objectMode` streams, and will
throw a `TypeError` from the constructor if the size argument is
missing or invalid.

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