Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mimic-response

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mimic-response - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

20

index.js

@@ -25,2 +25,6 @@ 'use strict';

module.exports = (fromStream, toStream) => {
if (toStream._readableState.autoDestroy) {
throw new Error('The second stream must have the `autoDestroy` option set to `false`');
}
const fromProperties = new Set(Object.keys(fromStream).concat(knownProperties));

@@ -54,6 +58,22 @@

fromStream.once('aborted', () => {
toStream.destroy();
toStream.emit('aborted');
});
fromStream.once('close', () => {
if (fromStream.complete) {
if (toStream.readable) {
toStream.once('end', () => {
toStream.emit('close');
});
} else {
toStream.emit('close');
}
} else {
toStream.emit('close');
}
});
return toStream;
};

2

package.json
{
"name": "mimic-response",
"version": "3.0.0",
"version": "3.1.0",
"description": "Mimic a Node.js HTTP response stream",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -51,30 +51,2 @@ # mimic-response [![Build Status](https://travis-ci.com/sindresorhus/mimic-response.svg?branch=master)](https://travis-ci.com/sindresorhus/mimic-response)

**Note #2:** The `aborted` and `close` events are not proxied. You have to add them manually:
```js
const stream = require('stream');
const mimicResponse = require('mimic-response');
const responseStream = getHttpResponseStream();
const myStream = new stream.PassThrough({
destroy(error, callback) {
responseStream.destroy();
callback(error);
}
});
responseStream.once('aborted', () => {
myStream.destroy();
myStream.emit('aborted');
});
responseStream.once('closed', () => {
myStream.emit('closed');
});
responseStream.pipe(myStream);
```
#### from

@@ -81,0 +53,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc