{"name":"mimic-response","version":"2.1.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":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["mimic","response","stream","http","https","request","get","core"],"devDependencies":{"@sindresorhus/tsconfig":"^0.3.0","@types/node":"^12.0.0","ava":"^1.1.0","create-test-server":"^2.4.0","pify":"^4.0.1","tsd":"^0.7.3","xo":"^0.24.0"},"gitHead":"94bd5a359bad199d801188473e48cb024c6f31ca","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"homepage":"https://github.com/sindresorhus/mimic-response#readme","_id":"mimic-response@2.1.0","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==","shasum":"d13763d35f613d09ec37ebb30bac0469c0ee8f43","tarball":"http://registry-npm.ywwl.com/mimic-response/download/mimic-response-2.1.0.tgz","fileCount":5,"unpackedSize":4734,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSjebCRA9TVsSAnZWagAALe8P/iFbctdjOJSaAm/zcobz\nbVfPgaosbkybakVYwKS3t0xRWOsMvo47ZafI405J0OiT+B6xrp+zeFxg5Ww+\nbF70Te4CubPA/8RmhEHAypBzt2SbqxhVkUpZbyzF7crAdgC3kzJGpB/ZcJbb\nrmh1rUuQbdGjyIhgYondVCL3eR5DvYiMIlfhEFTtOeqCU7Wj4C26rZ9oCMu3\n8dwLoXG8fqsdFG1cqBFpZqmKvpEQG0fITcle1LsMfeGt6xqmaPC3Cis5Jf5f\nj4HjT7CgCKIQiEa/78dOqA1rxUEMvx72wzpeIUUQrcEUC0XLmWIHW4I036sK\nSUOhJ0dTJAEo8Y3PG9mUY639WVLe9oUiYslavX/kVl5kNsSOpA3ZRCRQm0fE\nf0RqFp7vW6/Amv0QqNYuUXhf/TR3lJeQ6sqvdQZbNW1bJfSLd42occxBN0AK\nJZ5VNC75kW/wqJeFg+ckSOOcGJyHhoxZj420qNB+aNu58DSGs+kBJ/FEcUDR\nhgeFs4KwzCKRfRHETe9Nhv0EOQG5yddTcuuRx8D070Nr82Ofq2QitUoDmz3k\nIqVVyVLf6fLJndAj2adI+4jlEZTF8e14B7I8Rh3LwiI5Yhihft7Qkf4v6Obu\nSVp4xqg2Y63nTx6Ev1Y3MvFONrGcLdEjSnr9VbzDwKNBoOXnlSzt6vEIfJr6\nsx9j\r\n=hu6u\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEqKSfiuiQ03jBVkRME0jsP0P7r1q1i4dqLS92s7ReeSAiAX9d47L4+rFLFfoa12GlXccPnaLGN9whx1vYLDWf9pGQ=="}],"size":2380,"noattachment":false,"key":"/mimic-response/-/mimic-response-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_2.1.0_1581922202617_0.29954897440523287"},"_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":1581922202733,"_cnpm_publish_time":1581922202733,"dist-tags":{"latest":"4.0.0"}}