{"name":"mimic-response","version":"4.0.0","description":"Mimic a Node.js HTTP response stream","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/mimic-response.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["mimic","response","stream","http","https","request","get","core"],"devDependencies":{"@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.17.0","xo":"^0.44.0"},"gitHead":"2cb991bc4801a88e0cff37768d41379fabaa8eef","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"homepage":"https://github.com/sindresorhus/mimic-response#readme","_id":"mimic-response@4.0.0","_nodeVersion":"16.2.0","_npmVersion":"7.10.0","dist":{"integrity":"sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==","shasum":"35468b19e7c75d10f5165ea25e75a5ceea7cf70f","tarball":"http://registry-npm.ywwl.com/mimic-response/download/mimic-response-4.0.0.tgz","fileCount":5,"unpackedSize":6201,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhE9+TCRA9TVsSAnZWagAA4UoP/3I+dhcbYLxgwla4hIDA\n2zoMS8GnnAJvsJHiO5WHUM1pRO/Fff+efIlMD1kCsu2kQsu5zrLmc+nqUkaC\nqLRzmGWStdCk6xiqJ+c6Vby2xMdZOmI/wohE46T/1XFngIjkpEMJM4xsnkIS\nKuXWpkymvK6SpHe6D2RqgTVmXzRuzwYV9TFMzLt9dMGEck/ETQt8LDQUO8nO\nqTR7V126KKnm7UMLnlbr833zchloqvXad84EBGSoJWqin6KMi+8HVSm+bXPu\nVyTF5ZjIuMwUu5uZO8qc0vx0iPjs4ixLCPduJM2Xj6DITAFHo7AlRy94a+LL\npR/5LfFKJXVCTqxIIYajO+oQ9IRK8PGs2yOJzMB6v5EaE59hNZ/dQyUleZra\nZ+K124rViRgeMZQwcTRGTWtnMuIqLuuhR7RWjoF31SNuvykH9U5hzbn8diGt\nXwzlThQyDvvJ/B6x3KTtmOwG5cBQMZZRIaiUk9wNTdLIYRZoB7l6N0tgrE0k\n7h1Sehd2c94dcUn1jtrZXw7k9GUUHg9MLEw0ItCWw7XiyN8LzdGPbZ/+MpH6\nvjAilvHy9kseszwbkY6Dldw6yyCcau6aBG7blBbqOZ5ezBCIJKPRW7YW5z/h\nGlZ75+wjrW6QkpXY12RhG0JubCUvu9Ad268gkYAn7pUAU8/pzHeuO6E4ZGJX\nvmqF\r\n=01/Y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/cSPcQTDLLSY1iCuXDp9FX9ok0TgeKl2KMeh3Yrpy5AIgLdDN+7earqBD7dPgs16aafC2c6BsuF08nYNs2csW3iQ="}],"size":2749,"noattachment":false,"key":"/mimic-response/-/mimic-response-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_4.0.0_1628692371184_0.7582342499964367"},"_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":1628692371305,"_cnpm_publish_time":1628692371305,"dist-tags":{"latest":"4.0.0"}}