{"name":"mimic-response","version":"3.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"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["mimic","response","stream","http","https","request","get","core"],"devDependencies":{"@types/node":"^14.0.1","ava":"^2.4.0","create-test-server":"^2.4.0","p-event":"^4.1.0","pify":"^5.0.0","tsd":"^0.11.0","xo":"^0.30.0"},"gitHead":"a198eb503208b023193512b7bf31a491915b774b","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"homepage":"https://github.com/sindresorhus/mimic-response#readme","_id":"mimic-response@3.0.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-vE8dqYbdBFxcvS5KofMTGZ9I8CA3m00em4jCAruysVt9KfS9lJnSPD47oBfPhZ/rYB1hyY027nEPifrQePfMig==","shasum":"b7cc6aa6aaec31e6b9b2f17488b258ade8e7aecf","tarball":"http://registry-npm.ywwl.com/mimic-response/download/mimic-response-3.0.0.tgz","fileCount":5,"unpackedSize":6145,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevDJ9CRA9TVsSAnZWagAA5P8QAJcXmo9iupBw4LH7YIIX\nOnEYEWh1PU0MCQcmVhJPcspDEDWKHNj/TIY754++fLwPqox8gvBInwV2Pv8F\nSbP+0jb+qmFN/0vAreiY8tdjICyV5ITtHdbwQbl0dK7gKN3TFAhsCwTwngCt\nXo/YqlOfQzw55wNaLMiuZM2DKOvc3k5tJYYrJhIvqPee4OdsieuMx1nuYjYf\nQ9WbPFPGedD41I3kViy4865T8nOsHTGVQ2RJXjYShartio3zPASS4Es7qkI9\nEF9E03yuIYqXqMqE12Gt0U3ou0dF5ocPWUSZuH66Pfy35QDKOAtb5nqmwAG8\nLJBdCGZPSmw1KvNmSNEpV6AV7iSRCTdIiApVfmi0rYO2zqd2MOhkeBzb+oYg\nXPaHnw5lMQdORZMTveqRDkjnBBVXlcdKY3tBBBKCSQcSz9gN1FYtUni0riih\n4YwBo3cRTNKWUvcTZ1wwZ4L8t4U8yffeIRPyuCAze+pzVJfk+2KpILD7yQBC\nSVs81Eyf7ZC0or0EGdPebTkdcnvww3oxeh+Sdyzbwbg7hcY5pPMc6y/llhRu\nYMhAUBCn6sQcumVuAoMxYZ/5ifKy8XzsTCa+l1mkHjB5HMEaPLhleCz+JpHM\nGnsnkZujjAa14wLGe3s0sacSronvLhGw7KZ+OE0kYgGtNYRNrj0pHj92RKaf\nEC6I\r\n=a/Vk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBAgs6uB6/nBHi4ZZSmbXLuSOootcnXCu4XXSofVSnfMAiEAuzETWGk16/lsogXhcqshhVkGsLxCs6riaOWi6kob0N4="}],"size":2765,"noattachment":false,"key":"/mimic-response/-/mimic-response-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_3.0.0_1589391996948_0.08494827744204869"},"_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":1589391997063,"_cnpm_publish_time":1589391997063,"dist-tags":{"latest":"4.0.0"}}