4.0.0 • Published 4 years ago

mimic-response v4.0.0

Weekly downloads
22,145,555
License
MIT
Repository
github
Last release
4 years ago

mimic-response

Mimic a Node.js HTTP response stream

Install

$ npm install mimic-response

Usage

import {PassThrough as PassThroughStream} from 'node:stream';
import mimicResponse from 'mimic-response';

const responseStream = getHttpResponseStream();
const myStream = new PassThroughStream();

mimicResponse(responseStream, myStream);

console.log(myStream.statusCode);
//=> 200

API

mimicResponse(from, to)

Note #1: The from.destroy(error) function is not proxied. You have to call it manually:

import {PassThrough as PassThroughStream} from 'node:stream';
import mimicResponse from 'mimic-response';

const responseStream = getHttpResponseStream();

const myStream = new PassThroughStream({
	destroy(error, callback) {
		responseStream.destroy();

		callback(error);
	}
});

myStream.destroy();

Please note that myStream and responseStream never throw. The error is passed to the request instead.

from

Type: Stream

Node.js HTTP response stream.

to

Type: Stream

Any stream.

Related


decompress-responsecacheable-requestclone-responsearchetype-libraryeasy-select-rnreact-native-bluetooth2got-blah-blah-testcloud-archive-s3airscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationdiscord-music-botsreact-native-covid-sdkeasycommands-beta@saeon/quick-formmysql-formatreact-native-printer-brothersreact-native-shekhar-bridge-testcogoportutilsdyx-reacttalent-to-vite-cli@oiti/documentoscopy-react-nativequoc-testone-indexunblock-block-save-variables@infinitebrahmanuniverse/nolb-mim@prodam/prodam-typesopea-bootstraapluminos-ui-core@everything-registry/sub-chunk-2170jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkg@finviet-jsrpt/jsrpt-client@rabailriaz/hisaab-web-portalreact-native-jawwy_samplegriffin-ui-librarytest-library-123test-haptik-libweb-elements-iconswebchewifi_configuration_packagewhatsconcteapackage-tatespoorman297sui-monorepotest-zeo-collectvision-camera-plugin-face-detectorvision-camera-plugin-scan-facesvision-camera-base64-resizedvantiq-reactvite_vue3_ts_ssssdddddyyyy@borealisswap/borealis-swap-libcauseway-concrete-stylesjeuxuijrennsoh88-react-native-scroll-indicatorjsreport-clientjesh-calculationjnf-accesscontrol-rnttljordy-frijters-test-libjametkafirchain-tetriskhaled-salem-custom-componentshw9img-sliceimg-slicerimdragons.jshong1-utilsliveprodmama-exporterm2m-chartjs-plugin-crosshairloading-animatedkooks@wecraftapps/react-native-use-keyboard@tlgeo/react-native-gdal@thismr/bitmindtest-core@thinxviewx/core-rn@tonysusi/vapid@vandai-nguyen/module_test@xsahxl/got@xswap/v2-core@xiwen5566/aqara-automation-switch@yplabs-ltd/react-native-detector@yak-spirit/yak-swap-ui@zalastax/nolb-mim@zotasys/nativeagent-get-agentadonis-ally-figmaangularvezbaaxios-yet-another-proxy-fixawesome-module-kdash07-currency-converterarchlibraryarvm-bestdeveloper@cleveradssolutions/cas.cordova.adcolony
4.0.0

4 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.1.0

6 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

8 years ago