Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

mimic-response

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Issues
File Explorer

Advanced tools

mimic-response

Mimic a Node.js HTTP response stream

    4.0.0latest

Version published
Maintainers
1
Weekly downloads
20,101,578
decreased by-11.06%

Weekly downloads

Changelog

Source

Breaking

  • Require Node.js 12.20 4e6faf4
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/mimic-response/compare/v3.1.0...v4.0.0

Readme

Source

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.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

What is mimic-response?

Mimic a Node.js HTTP response stream

Is mimic-response popular?

The npm package mimic-response receives a total of 16,151,253 weekly downloads. As such, mimic-response popularity was classified as popular.

Is mimic-response well maintained?

We found that mimic-response demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 11 Aug 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
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