{"_id":"mimic-response","_rev":"521047","name":"mimic-response","description":"Mimic a Node.js HTTP response stream","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2021-08-11T14:35:46.000Z","created":"2017-06-02T17:46:00.485Z","4.0.0":"2021-08-11T14:32:51.305Z","3.1.0":"2020-05-14T18:31:02.911Z","3.0.0":"2020-05-13T17:46:37.063Z","2.1.0":"2020-02-17T06:50:02.733Z","2.0.0":"2019-01-20T10:31:54.203Z","1.0.1":"2018-07-11T11:25:07.279Z","1.0.0":"2017-06-02T17:46:00.485Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/mimic-response.git"},"versions":{"4.0.0":{"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":{"shasum":"35468b19e7c75d10f5165ea25e75a5ceea7cf70f","size":2749,"noattachment":false,"key":"/mimic-response/-/mimic-response-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mimic-response/download/mimic-response-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_4.0.0_1628692371184_0.7582342499964367"},"_hasShrinkwrap":false,"publish_time":1628692371305,"_cnpm_publish_time":1628692371305},"3.1.0":{"name":"mimic-response","version":"3.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":">=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":"d431140fc079b922aa8c998bee0e85b1ffe74e48","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"homepage":"https://github.com/sindresorhus/mimic-response#readme","_id":"mimic-response@3.1.0","_nodeVersion":"10.20.1","_npmVersion":"6.14.4","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"2d1d59af9c1b129815accc2c46a022a5ce1fa3c9","size":2822,"noattachment":false,"key":"/mimic-response/-/mimic-response-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mimic-response/download/mimic-response-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_3.1.0_1589481062774_0.7721786284338883"},"_hasShrinkwrap":false,"publish_time":1589481062911,"_cnpm_publish_time":1589481062911},"3.0.0":{"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":{"shasum":"b7cc6aa6aaec31e6b9b2f17488b258ade8e7aecf","size":2765,"noattachment":false,"key":"/mimic-response/-/mimic-response-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mimic-response/download/mimic-response-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_3.0.0_1589391996948_0.08494827744204869"},"_hasShrinkwrap":false,"publish_time":1589391997063,"_cnpm_publish_time":1589391997063},"2.1.0":{"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":{"shasum":"d13763d35f613d09ec37ebb30bac0469c0ee8f43","size":2380,"noattachment":false,"key":"/mimic-response/-/mimic-response-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mimic-response/download/mimic-response-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_2.1.0_1581922202617_0.29954897440523287"},"_hasShrinkwrap":false,"publish_time":1581922202733,"_cnpm_publish_time":1581922202733},"2.0.0":{"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":{"shasum":"996a51c60adf12cb8a87d7fb8ef24c2f3d5ebb46","size":1898,"noattachment":false,"key":"/mimic-response/-/mimic-response-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mimic-response/download/mimic-response-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_2.0.0_1547980314105_0.26240773097676384"},"_hasShrinkwrap":false,"publish_time":1547980314203,"_cnpm_publish_time":1547980314203},"1.0.1":{"name":"mimic-response","version":"1.0.1","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":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["mimic","response","stream","http","https","request","get","core"],"devDependencies":{"ava":"*","create-test-server":"^0.1.0","pify":"^3.0.0","xo":"*"},"gitHead":"687b4544afddca3d3e9e61a455ca5efe0e27851e","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"homepage":"https://github.com/sindresorhus/mimic-response#readme","_id":"mimic-response@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"4923538878eef42063cb8a3e3b0798781487ab1b","size":1894,"noattachment":false,"key":"/mimic-response/-/mimic-response-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mimic-response/download/mimic-response-1.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response_1.0.1_1531308307178_0.4318628271748308"},"_hasShrinkwrap":false,"publish_time":1531308307279,"_cnpm_publish_time":1531308307279},"1.0.0":{"name":"mimic-response","version":"1.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":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["mimic","response","stream","http","https","request","get","core"],"devDependencies":{"ava":"*","create-test-server":"^0.1.0","pify":"^3.0.0","xo":"*"},"gitHead":"44a0267b744d0006b89f69fafc468ed6abbb612b","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"homepage":"https://github.com/sindresorhus/mimic-response#readme","_id":"mimic-response@1.0.0","_shasum":"df3d3652a73fded6b9b0b24146e6fd052353458e","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"df3d3652a73fded6b9b0b24146e6fd052353458e","size":1919,"noattachment":false,"key":"/mimic-response/-/mimic-response-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mimic-response/download/mimic-response-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-response-1.0.0.tgz_1496425560359_0.6087012456264347"},"directories":{},"publish_time":1496425560485,"_hasShrinkwrap":false,"_cnpm_publish_time":1496425560485}},"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","_attachments":{},"homepage":"https://github.com/sindresorhus/mimic-response#readme","bugs":{"url":"https://github.com/sindresorhus/mimic-response/issues"},"license":"MIT"}