# duplexer3

> Modern version of `duplexer2`

Latest version **1.0.0** (published 2022-07-07) · BSD-3-Clause license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-07-07 |
| First published | 2016-01-11 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | separate (@types/duplexer3) |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 0 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Maintainers | floatdrop, sindresorhus |
| Keywords | duplex, duplexer, stream, streams, join, combine |

## Links

- npm: https://www.npmjs.com/package/duplexer3
- Repository: https://github.com/sindresorhus/duplexer3
- Homepage: https://github.com/sindresorhus/duplexer3#readme
- Issues: https://github.com/sindresorhus/duplexer3/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/duplexer3

## 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.0.0 (latest) — 2022-07-07
- 0.1.5 — 2022-07-07
- 0.1.4 — 2016-01-11

## README

# duplexer3

> Modern version of `duplexer2`

## Install

```sh
npm install duplexer3
```

## Usage

```js
import stream from 'node:stream';
import duplexer from 'duplexer3';

const writable = new stream.Writable({objectMode: true});
const readable = new stream.Readable({objectMode: true});

writable._write = function (input, encoding, done) {
	if (readable.push(input)) {
		done();
	} else {
		readable.once('drain', done);
	}
};

readable._read = function () {
	// Noop
};

// Simulate the readable thing closing after a bit
writable.once('finish', () => {
	setTimeout(() => {
		readable.push(null);
	}, 500);
});

const duplex = duplexer3(writable, readable);

duplex.on('data', data => {
	console.log('got data', JSON.stringify(data));
});

duplex.on('finish', () => {
	console.log('got finish event');
});

duplex.on('end', () => {
	console.log('got end event');
});

duplex.write('oh, hi there', () => {
	console.log('finished writing');
});

duplex.end(() => {
	console.log('finished ending');
});
```

```
got data 'oh, hi there'
finished writing
got finish event
finished ending
got end event
```

## API

### duplexer(options?, writableStream, readableStream)

#### options

Type: `object`

##### bubbleErrors

Type: `boolean`\
Default: `true`

Whether to bubble errors from the underlying readable/writable streams.

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