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.1.0 to 4.0.0

22

index.d.ts

@@ -1,2 +0,2 @@

import {IncomingMessage} from 'http';
import {IncomingMessage} from 'node:http';

@@ -11,8 +11,20 @@ /**

@return The same object as `toStream`.
@example
```
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
```
*/
declare function mimicResponse<T extends NodeJS.ReadableStream>(
fromStream: IncomingMessage, // eslint-disable-line @typescript-eslint/prefer-readonly-parameter-types
export default function mimicResponse<T extends NodeJS.ReadableStream>(
fromStream: IncomingMessage,
toStream: T,
): T & IncomingMessage;
export = mimicResponse;

@@ -1,3 +0,1 @@

'use strict';
// We define these manually to ensure they're always copied

@@ -21,6 +19,6 @@ // even if they would move up the prototype chain

'trailers',
'url'
'url',
];
module.exports = (fromStream, toStream) => {
export default function mimicResponse(fromStream, toStream) {
if (toStream._readableState.autoDestroy) {

@@ -30,3 +28,3 @@ throw new Error('The second stream must have the `autoDestroy` option set to `false`');

const fromProperties = new Set(Object.keys(fromStream).concat(knownProperties));
const fromProperties = new Set([...Object.keys(fromStream), ...knownProperties]);

@@ -52,3 +50,3 @@ const properties = {};

enumerable: true,
configurable: false
configurable: false,
};

@@ -80,2 +78,2 @@ }

return toStream;
};
}
{
"name": "mimic-response",
"version": "3.1.0",
"version": "4.0.0",
"description": "Mimic a Node.js HTTP response stream",

@@ -13,4 +13,6 @@ "license": "MIT",

},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@@ -35,10 +37,10 @@ "scripts": {

"devDependencies": {
"@types/node": "^14.0.1",
"ava": "^2.4.0",
"create-test-server": "^2.4.0",
"p-event": "^4.1.0",
"@types/node": "^16.4.13",
"ava": "^3.15.0",
"create-test-server": "^3.0.1",
"p-event": "^4.2.0",
"pify": "^5.0.0",
"tsd": "^0.11.0",
"xo": "^0.30.0"
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}

@@ -1,2 +0,2 @@

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

@@ -14,7 +14,7 @@ > Mimic a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage)

```js
const stream = require('stream');
const mimicResponse = require('mimic-response');
import {PassThrough as PassThroughStream} from 'node:stream';
import mimicResponse from 'mimic-response';
const responseStream = getHttpResponseStream();
const myStream = new stream.PassThrough();
const myStream = new PassThroughStream();

@@ -34,8 +34,8 @@ mimicResponse(responseStream, myStream);

```js
const stream = require('stream');
const mimicResponse = require('mimic-response');
import {PassThrough as PassThroughStream} from 'node:stream';
import mimicResponse from 'mimic-response';
const responseStream = getHttpResponseStream();
const myStream = new stream.PassThrough({
const myStream = new PassThroughStream({
destroy(error, callback) {

@@ -51,3 +51,3 @@ responseStream.destroy();

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

@@ -54,0 +54,0 @@ #### from

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