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@cs6/react-native-test-native-view-library@con-test/react-native-concent-common@damruravihara/react-native-testing-package@corelmax/react-native-my2c2p-sdk@devenjadhav/notion-todo-list@borealisswap/borealis-swap-lib@praella/localisationistcauseway-concrete-stylesjeuxuijrennsoh88-react-native-scroll-indicatorjsreport-clientjesh-calculationjnf-accesscontrol-rnttljordy-frijters-test-libjametkafirchain-tetriskhaled-salem-custom-componentsgomantic_releasejawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwytest_lib_module_aarquickcapture_react_nativern-agora-ios-mzzzxxxyyy321123web-yii2react-native-omental-frameworkreact-native-sixdee_test_libtingzi-vuepresstinymce-plugin-toytldrawlignintwine-libtwine-library@amiruldev/wajs@amirdiafi/react-native-ios-haptics@apardellass/react-native-audio-stream@aspecto/core@asiz33/smartblok-vendure-plugin@aviinash_jha/react-native-test_multiply@afria/afria-libraries@ali5049/react-native-buttons@bee-icons/qwik
4.0.0

4 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.1.0

5 years ago

2.0.0

6 years ago

1.0.1

7 years ago

1.0.0

8 years ago