# streamtester

> A writable stream which can perform specified tests on the written data

Latest version **0.3.0** (published 2026-05-13) · ISC license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2026-05-13 |
| First published | 2015-08-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.6.0 |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Adrian Sieber |
| Maintainers | adius |
| Keywords | stream, test |

## Links

- npm: https://www.npmjs.com/package/streamtester
- Repository: https://github.com/adius/streamtester
- Homepage: https://github.com/adius/streamtester#readme
- Issues: https://github.com/adius/streamtester/issues
- npm.io page: https://npm.io/package/streamtester

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2026-05-13
- 0.2.0 — 2016-08-24
- 0.1.0 — 2015-08-03

## README

# StreamTester

A writable stream which can perform specified tests on the written data.

## Installation

```shell
npm install --save-dev streamtester
```

## Usage

```ts
import { createReadStream } from "node:fs"
import { strict as assert } from "node:assert"
import { StreamTester } from "streamtester"

const streamTester = new StreamTester({
  test: (chunk) => {
    assert.equal(JSON.parse(String(chunk)).name, "streamtester")
  },
})

createReadStream("./package.json").pipe(streamTester)
```

### Options

- `test(chunk)` — called for every chunk (or, when `filter` is set, for every truthy filtered chunk).
- `filter(chunk)` — transforms a chunk before testing. Falsy return values skip the chunk.
- `testFirst(chunk)` — called once with the first chunk written to the stream.

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