Big update!Announcing Socket for GitHub 1.0. Learn more
Socket
BlogLoveFAQ
Install
Log in

responselike

Package Overview
Dependencies
1
Maintainers
2
Versions
8
Issues
File Explorer

Advanced tools

responselike

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

    3.0.0latest

Version published
Maintainers
2
Weekly downloads
14,684,479
increased by0.06%

Weekly downloads

Changelog

Source

Breaking

  • Require Node.js 14 5a96ab4
  • This package is now pure ESM. Please read this.
  • It now accept an object instead of multiple parameters:
    • new Response(200, …) => new Response({statusCode: 200, …})

https://github.com/sindresorhus/responselike/compare/v2.0.0...v3.0.0

Readme

Source

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.

Keywords

FAQs

What is responselike?

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

Is responselike popular?

The npm package responselike receives a total of 11,924,796 weekly downloads. As such, responselike popularity was classified as popular.

Is responselike well maintained?

We found that responselike demonstrated a healthy version release cadence and project activity. It has 2 open source maintainers collaborating on the project.

Last updated on 18 Jul 2022
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc