# syncthrough

> A Transform stream that is sync, and very fast

Latest version **1.1.0** (published 2026-04-02) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-04-02 |
| First published | 2017-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 110 |
| Author | Matteo Collina |
| Maintainers | matteo.collina |
| Keywords | streams, stream, transform, through, through2 |

## Links

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

## 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

- 1.1.0 (latest) — 2026-04-02
- 1.0.0 — 2024-01-11
- 0.5.0 — 2017-03-22
- 0.4.0 — 2017-01-26
- 0.3.1 — 2017-01-15
- 0.3.0 — 2017-01-15
- 0.2.0 — 2017-01-10
- 0.1.2 — 2017-01-03
- 0.1.1 — 2017-01-02
- 0.1.0 — 2017-01-02

## README

# syncthrough&nbsp;&nbsp;[![ci](https://github.com/mcollina/syncthrough/actions/workflows/ci.yml/badge.svg)](https://github.com/mcollina/syncthrough/actions/workflows/ci.yml)

Transform your data as it pass by, synchronously.

**syncthrough** is a synchronous transform stream, similar to [Transform
stream][transform] and [through2](https://github.com/rvagg/through2), but with a synchronous processing function.
**syncthrough** enforces backpressure, but it maintain no internal
buffering, allowing much greater throughput.
In fact, it delivers 10x performance over a standard
[`Transform`][transform].

Because of the [caveats](#caveats), it is best used in combination of
[`pipe()`][pipe], [`pump()`][pump], [`pipeline()`][pipeline], or `stream.compose()`.

## Install

```
npm i syncthrough --save
```

## Example

```js
import { createReadStream } from 'node:fs'
import { pipeline } from 'node:stream/promises'
import { syncthrough } from 'syncthrough'

await pipeline(
  createReadStream(import.meta.filename),
  syncthrough(function (chunk) {
    // there is no callback here
    // you can return null to end the stream
    // returning undefined will let you skip this chunk
    return chunk.toString().toUpperCase()
  }),
  process.stdout)
```

## API

### syncthrough([transform(chunk)], [flush()])

Returns a new instance of `syncthrough`, where `transform(chunk)` is the
transformation that will be applied to all incoming chunks.

The default `transform` function is:

```js
function (chunk) {
  return chunk
}
```

If it returns `null`, the stream will be closed. If it returns
`undefined`, the chunk will be skipped.

There is currently no way to split an incoming chunk into multiple
chunks.

The `flush()` function will be called before the transform sends `end()`
on the destination.

### syncthrough([transform(object)], [flush()])

Returns a new instance of `syncthrough`, where `transform(object)` is the
transformation that will be applied to all incoming objects.

Syncthrough is compatible with Streams in [Object Mode](https://nodejs.org/api/stream.html#stream_object_mode),
the API is exactly the same, simply expect objects instead of buffer chunks.

### instance.push(chunk)

Push a chunk to the destination.

## Caveats

The API is the same of a streams 3 [`Transform`][transform], with some major differences:

1. *backpressure is enforced*, and the instance performs no buffering,
   e.g. when `write()` cannot be called after it returns false or it will `throw`
   (you need to wait for a `'drain'` event).
2. It does not inherits from any of the Streams classes, and it does not
   have `_readableState` nor `_writableState`.
3. it does not have a `read(n)` method, nor it emits the
   `'readable'` event, the data is pushed whenever ready.

<a name="acknowledgements"></a>
## Acknowledgements

This project was kindly sponsored by [nearForm](http://nearform.com).

## License

MIT

[transform]: https://nodejs.org/api/stream.html#stream_class_stream_transform
[pipe]: https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
[pump]: https://github.com/mafintosh/pump
[pipeline]: https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options

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