1.0.0 • Published 3 years ago

duplexer3 v1.0.0

Weekly downloads
12,693,768
License
BSD-3-Clause
Repository
github
Last release
3 years ago

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.

archetype-libraryreact-native-bluetooth2killi8n-react-native-fast-imagegot-blah-blah-testcad-cli@cashremit/cr-streamline-iconsairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationdiscord-music-botsreact-native-covid-sdk@saeon/ol-react@saeon/quick-formmysql-formatreact-native-printer-brotherscogoportutilsdyx-reacttalent-to-vite-clione-indexunblock-block-save-variables@infinitebrahmanuniverse/nolb-dup@prodam/prodam-types@everything-registry/sub-chunk-1538tap-ontap-minweb-elements-iconswebchewhatsconcteapackage-tatespoorman297spooky2test-public-provision-camera-plugin-scan-facesvdv-451-readervite_vue3_ts_ssssdddddyyyy@con-test/react-native-concent-common@corelmax/react-native-my2c2p-sdk@borealisswap/borealis-swap-lib@rstacruz/pnpmcauseway-concrete-stylesjeuxuijnf-accesscontrol-rnttljm-etljametlazy-bee-uiud7-act2tingzi-vuepressuimotwine-libtwine-library@apardellass/react-native-audio-stream@asiz33/smartblok-vendure-plugin@bee-icons/qwik@bkrmadtya/sorting-steps@chiaraani/bouncing-ball@chakra-swap/core@bonsaiswap-lib/lib@bonsaiswapv3/core@bonsaiswapv3/deployyangotyangzai-cliyf-sw-clivue-v3-yandex-metrikawangyaling-1awcq-vuewant-have-replication@felipesimmi/react-native-datalogic-module@hawkingnetwork/react-native-tab-view@hbglobal/react-native-actions-shortcuts@geeky-apo/react-native-advanced-clipboard@eliteswap/v2-core@innoswap/core@innodata/vue-v3-ya-metrika@kumardeo/file-size@livecycle.io/rrweb-snapshot@litedexdev/litedex-core-swap@marinaga/bananize@materia-dex/materia-contracts-proxy@nandhakumarb/npm_sample@navabi/react-native-ssl-pinning@nodeberry/solidity-payment-processor@enkeledi/react-native-week-month-date-picker@faizanhaider/iconsax@moezx/meting@johnhamlin/redux-persist@johnpyp/etl@kodinghandle/bullswap-lib@ko-developerhong/react-native-multiple-image-picker@imrtoy/homebridge-night-light@jfilipe-sparta/react-native-module_2@hemith/react-native-tnk@igniswap/igni-swap-lib@kacao/chops@olympfin/olymp-swap-lib@prantlf/faucet@saad27/react-native-bottom-tab-tour@samwinslow/edgedb@npm-lt/cli
1.0.0

3 years ago

0.1.5

3 years ago

0.1.4

10 years ago