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@borealisswap/borealis-swap-libcauseway-concrete-stylesjeuxuijnf-accesscontrol-rnttljm-etljametlazy-bee-uihw9hubot-budaherculemama-exporterm2m-chartjs-plugin-crosshairkooks@wecraftapps/react-native-use-keyboard@thismr/bitmindtest-core@tonysusi/vapid@vandai-nguyen/module_test@xsahxl/got@xswap/v2-core@xiwen5566/aqara-automation-switch@yplabs-ltd/react-native-detector@yak-spirit/yak-swap-uiarvm-bestdeveloper@cleveradssolutions/cas.cordova.adcolony@cleveradssolutions/cas.cordova.admob@cleveradssolutions/cas.cordova.applovin@cleveradssolutions/cas.cordova.facebook@cleveradssolutions/cas.cordova.families@cleveradssolutions/cas.cordova.fyber@cleveradssolutions/cas.cordova.optimal@cleveradssolutions/cas.cordova.pangle@cleveradssolutions/cas.cordova.superawesome@cleveradssolutions/cas.cordova.tapjoy@cleveradssolutions/cas.cordova.unity@cleveradssolutions/cas.cordova.vungle@cleveradssolutions/cas.cordova.yandex@cleveradssolutions/cas.cordova.inmobi@cleveradssolutions/cas.cordova.ironsource@cleveradssolutions/cas.cordova.kidoz@cleveradssolutions/cas.cordova.mintegral@cleveradssolutions/cas.cordova.mytarget@happy-gastro/react-native-printer-module@gteam_uz/create-me-app@con-test/react-native-concent-common@corelmax/react-native-my2c2p-sdk@hawkingnetwork/react-native-tab-view@hbglobal/react-native-actions-shortcutsud7-act2tingzi-vuepressuimotwine-libtwine-library@bkrmadtya/sorting-steps@chiaraani/bouncing-ball@chakra-swap/core@bonsaiswap-lib/lib@bonsaiswapv3/core@bonsaiswapv3/deployyangotyangzai-cliyf-sw-clivue-v3-yandex-metrikawangyaling-1a
1.0.0

3 years ago

0.1.5

3 years ago

0.1.4

10 years ago