mimic-response

WebJar for mimic-response

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

mimic-response
Last Version

Last Version

2.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

mimic-response
WebJar for mimic-response
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/mimic-response

Download mimic-response

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/mimic-response/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>mimic-response</artifactId>
    <version>2.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/mimic-response/
implementation 'org.webjars.npm:mimic-response:2.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/mimic-response/
implementation ("org.webjars.npm:mimic-response:2.1.0")
'org.webjars.npm:mimic-response:jar:2.1.0'
<dependency org="org.webjars.npm" name="mimic-response" rev="2.1.0">
  <artifact name="mimic-response" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='mimic-response', version='2.1.0')
)
libraryDependencies += "org.webjars.npm" % "mimic-response" % "2.1.0"
[org.webjars.npm/mimic-response "2.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

mimic-response Build Status

Mimic a Node.js HTTP response stream

Install

$ npm install mimic-response

Usage

const stream = require('stream');
const mimicResponse = require('mimic-response');

const responseStream = getHttpResponseStream();
const myStream = new stream.PassThrough();

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:

const stream = require('stream');
const mimicResponse = require('mimic-response');

const responseStream = getHttpResponseStream();

const myStream = new stream.PassThrough({
	destroy(error, callback) {
		responseStream.destroy();

		callback(error);
	}
});

myStream.destroy();

Please note that myStream and responseStream never throws. The error is passed to the request instead.

from

Type: Stream

Node.js HTTP response stream.

to

Type: Stream

Any stream.

Related


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.

Versions

Version
2.1.0
1.0.1
1.0.0