{"name":"mimic-response","version":"2.0.0","description":"Mimic a Node.js HTTP response stream","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/mimic-response.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava"},"keywords":["mimic","response","stream","http","https","request","get","core"],"devDependencies":{"ava":"^1.1.0","create-test-server":"^2.4.0","pify":"^4.0.1","xo":"^0.24.0"},"gitHead":"bffa6bf1a91dc8bbede268948fdfa16af214f504","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"homepage":"https://github.com/sindresorhus/mimic-response#readme","_id":"mimic-response@2.0.0","_npmVersion":"6.5.0","_nodeVersion":"10.13.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-8ilDoEapqA4uQ3TwS0jakGONKXVJqpy+RpM+3b7pLdOjghCrEiGp9SRkFbUHAmZW9vdnrENWHjaweIoTIJExSQ==","shasum":"996a51c60adf12cb8a87d7fb8ef24c2f3d5ebb46","tarball":"http://registry-npm.ywwl.com/mimic-response/download/mimic-response-2.0.0.tgz","fileCount":4,"unpackedSize":3596,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcRE4aCRA9TVsSAnZWagAA2DEP/3fTjr0sQOf98GM1H6s+\nR5gk2+ABDSFs98EY79aJc4LfBMgmH7udH7hl1uZTZIyXaB5zjiAWvQ8435wp\nmQb9u3NN9CA9LTq2S8eFvCfkPVWrDRQG1fD/xhj15Srj38evVEuHH40RsTDE\nvCloJUnFdEL76hPp/+SY89pCKppp7iTfDhICTqGjDvDXS/TDhflY9y1qT1Js\nx+iKPV8K2a1ttT4XVHofop7mAPyT5cmNIn1TRT5dUSrQi2QYQ+AwnTFN96Cy\nCPLwobKTl+YubOkUEIcO9y4SHxMQGodqGUO/KQiiU5wDOOPDEbBIXIW7r8Kh\nqjxJ9gTnnX7JEifmG5KurjyMo5HIDuYLIY58V4zmxolo4rHJk8DIwIhV0DN6\na1OLjgnv7L9W8v+BnF/eu4d5+lWnsoYolX0fQKpuxiK13phXL9FyjGswBug0\nQqVViMXz7tRFqKG8uBO+ARX3eYN43/+SBJYAuf1SsCHMmLuQS+mcbnrbE18J\nYi8Zs/W7d6njyrYdr19a0nu0kXNxtwMmzt0ceBl3jowgSv1KxLbRCz2gcVHU\nr3KdHIDkfKgKrlzi4/pbBrmKo389MRxSP5qK8kesb5dq1/3uD1zWxwiSPcQb\ntW1JRH2CQKufIg12nHpjqASz06QHD/0Gj4eYMaB9QLdu5uu0x3uMnk/KLiLs\nwjSG\r\n=Qhei\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAcg03DS6ACJOGx0T56egLgDJobMkzCS2pvUQVlI0Y7QAiBveOBvm6+CU0uff0M5se6SsNTGwmTpzz+o6aYA9nxRJw=="}],"size":1898,"noattachment":false,"key":"/mimic-response/-/mimic-response-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_2.0.0_1547980314105_0.26240773097676384"},"_hasShrinkwrap":false,"readme":"# mimic-response\n\n> Mimic a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage)\n\n## Install\n\n```\n$ npm install mimic-response\n```\n\n## Usage\n\n```js\nimport {PassThrough as PassThroughStream} from 'node:stream';\nimport mimicResponse from 'mimic-response';\n\nconst responseStream = getHttpResponseStream();\nconst myStream = new PassThroughStream();\n\nmimicResponse(responseStream, myStream);\n\nconsole.log(myStream.statusCode);\n//=> 200\n```\n\n## API\n\n### mimicResponse(from, to)\n\n**Note #1:** The `from.destroy(error)` function is not proxied. You have to call it manually:\n\n```js\nimport {PassThrough as PassThroughStream} from 'node:stream';\nimport mimicResponse from 'mimic-response';\n\nconst responseStream = getHttpResponseStream();\n\nconst myStream = new PassThroughStream({\n\tdestroy(error, callback) {\n\t\tresponseStream.destroy();\n\n\t\tcallback(error);\n\t}\n});\n\nmyStream.destroy();\n```\n\nPlease note that `myStream` and `responseStream` never throw. The error is passed to the request instead.\n\n#### from\n\nType: `Stream`\n\n[Node.js HTTP response stream.](https://nodejs.org/api/http.html#http_class_http_incomingmessage)\n\n#### to\n\nType: `Stream`\n\nAny stream.\n\n## Related\n\n- [mimic-fn](https://github.com/sindresorhus/mimic-fn) - Make a function mimic another one\n- [clone-response](https://github.com/lukechilds/clone-response) - Clone a Node.js response stream\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-mimic-response?utm_source=npm-mimic-response&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","publish_time":1547980314203,"_cnpm_publish_time":1547980314203,"dist-tags":{"latest":"4.0.0"}}