3.0.0 • Published 3 years ago

responselike v3.0.0

Weekly downloads
17,025,265
License
MIT
Repository
github
Last release
3 years ago

responselike

A response-like object for mocking a Node.js HTTP response stream

Returns a streamable response object similar to a Node.js HTTP response stream. Useful for formatting cached responses so they can be consumed by code expecting a real response.

Install

npm install responselike

Usage

import Response from 'responselike';

const response = new Response({
	statusCode: 200,
	headers: {
		foo: 'bar'
	},
	body: Buffer.from('Hi!'),
	url: 'https://example.com'
});

response.statusCode;
// 200

response.headers;
// {foo: 'bar'}

response.body;
// <Buffer 48 69 21>

response.url;
// 'https://example.com'

response.pipe(process.stdout);
// 'Hi!'

API

new Response(options?)

Returns a streamable response object similar to a Node.js HTTP response stream.

options

Type: object

statusCode

Type: number

The HTTP response status code.

headers

Type: object

The HTTP headers. Keys will be automatically lowercased.

body

Type: Buffer

The response body. The Buffer contents will be streamable but is also exposed directly as response.body.

url

Type: string

The request URL string.

gotcacheable-requestarchetype-libraryeasy-select-rnreact-native-bluetooth2airscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationdiscord-music-botsreact-native-covid-sdk@saeon/quick-formmysql-formatreact-native-printer-brothersreact-native-shekhar-bridge-testcogoportutilsdyx-reacttalent-to-vite-cli@oiti/documentoscopy-react-nativequoc-testone-indexunblock-block-save-variables@prodam/prodam-typesopea-bootstraapluminos-ui-core@everything-registry/sub-chunk-2658jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkg@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-indicatorjesh-calculationjnf-accesscontrol-rnttljordy-frijters-test-libjametkhaled-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@asiz33/smartblok-vendure-plugin@aviinash_jha/react-native-test_multiply@afria/afria-libraries@ali5049/react-native-buttons@bee-icons/qwik@aysea/react-native-ui-library@bkrmadtya/sorting-steps@carllewi2/sapcdc-ally-driver@brantalikp/rn-resize@cdk8s-extensions/argo-rollout@chakra-swap/core@cleveradssolutions/cas.cordova.ironsource@cleveradssolutions/cas.cordova.kidoz@cleveradssolutions/cas.cordova.mintegral
3.0.0

3 years ago

2.0.1

3 years ago

2.0.0

6 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago