1.0.0 • Published 2 years ago

duplexer3 v1.0.0

Weekly downloads
12,693,768
License
BSD-3-Clause
Repository
github
Last release
2 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-1538@eliteswap/v2-core@enkeledi/react-native-week-month-date-picker@jfilipe-sparta/react-native-module_2@kacao/chops@ko-developerhong/react-native-multiple-image-picker@litedexdev/litedex-core-swap@livecycle.io/rrweb-snapshot@kodinghandle/bullswap-lib@kumardeo/file-size@innoswap/core@innodata/vue-v3-ya-metrika@marinaga/bananize@materia-dex/materia-contracts-proxy@npm-lt/cli@phong95/react-native-multiple-image-picker@nandhakumarb/npm_sample@moezx/meting@nodeberry/solidity-payment-processor@geeky-apo/react-native-advanced-clipboard@faizanhaider/iconsax@felipesimmi/react-native-datalogic-module@olympfin/olymp-swap-lib@orschweitzer/git-clone-package@navabi/react-native-ssl-pinning@prantlf/faucet@sudophunk/fulido@thismr/bitmindtest-core@tonysusi/vapid@igniswap/igni-swap-lib@imrtoy/homebridge-night-light@johnpyp/etl@johnhamlin/redux-persist@rstacruz/pnpm@serverless-devs/got@samwinslow/edgedb@saad27/react-native-bottom-tab-tourlazy-bee-ui@taingo97/react-native-telpo-printer@taingo97/react-native-expo-key-rsa-kt@taingo97/react-native-expo-rsa@taingo97/react-native-rsa@hawkingnetwork/react-native-tab-view@hbglobal/react-native-actions-shortcuts@hemith/react-native-tnk@gteam_uz/create-me-appm2m-chartjs-plugin-crosshairmama-exportermpesa-cookiempesa-cookie-jar@yplabs-ltd/react-native-detector@wecraftapps/react-native-use-keyboardpolen-web-components-reactpixiu-swap-corepixiuswap-libs-sdkbirken-react-native-community-image-editorcblink-cliover-armour-masterpayutestingplug2proxymicro-sub-climiracle-webpack-tree-shaking@xiwen5566/aqara-automation-switchmiguelcostero-ng2-toasty@xswap/v2-core@yak-spirit/yak-swap-ui@xsahxl/gotdiscord.js-bycondiscordjs-con-selfrfp-libreact-native-responsive-sizereact-native-sayhello-modulereact-native-kakao-mapsreact-native-teads-sdk-modulereact-native-my-first-try-arun-ramya
1.0.0

2 years ago

0.1.5

2 years ago

0.1.4

8 years ago