Big update!Introducing GitHub Bot Commands. Learn more
Socket
BlogLoveLog in
Book a demo

duplexer3

Package Overview
Dependencies
0
Maintainers
2
Versions
3
Issues
File Explorer

Advanced tools

duplexer3

Modern version of `duplexer2`

    1.0.0latest

Version published
Maintainers
2
Weekly downloads
10,338,500
increased by0.74%

Weekly downloads

Changelog

Source

Breaking

  • Require Node.js 14 413a549
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/duplexer3/compare/v0.1.5...v1.0.0

Readme

Source

duplexer3

Modern version of duplexer2

Install

npm install duplexer3

Usage

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.

Keywords

FAQs

What is duplexer3?

Modern version of `duplexer2`

Is duplexer3 popular?

The npm package duplexer3 receives a total of 9,906,116 weekly downloads. As such, duplexer3 popularity was classified as popular.

Is duplexer3 well maintained?

We found that duplexer3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.

Last updated on 07 Jul 2022
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc