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

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,599,575
decreased by-0.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,747,287 weekly downloads. As such, mimic-response popularity was classified as popular.

Is mimic-response well maintained?

We found that mimic-response demonstrated a healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.

Last updated on 11 Aug 2021
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