{"name":"clone-response","version":"0.2.1","description":"Clone a Node.js response object","main":"src/index.js","scripts":{"test":"xo && nyc ava","coverage":"nyc report --reporter=text-lcov | coveralls"},"xo":{"extends":"xo-lukechilds"},"repository":{"type":"git","url":"git+https://github.com/lukechilds/clone-response.git"},"keywords":["async","asynchronous","non-blocking","base64","encode","decode"],"author":{"name":"Luke Childs","email":"lukechilds123@gmail.com","url":"http://lukechilds.co.uk"},"license":"MIT","bugs":{"url":"https://github.com/lukechilds/clone-response/issues"},"homepage":"https://github.com/lukechilds/clone-response","dependencies":{"mimic-response":"^1.0.0"},"devDependencies":{"ava":"^0.19.1","coveralls":"^2.13.1","create-test-server":"^0.1.0","eslint-config-xo-lukechilds":"^1.0.0","get-stream":"^3.0.0","nyc":"^10.3.2","pify":"^3.0.0","xo":"^0.19.0"},"gitHead":"9b1128d5758d4669d4f1b4db6ef6a7cb5495ed65","_id":"clone-response@0.2.1","_npmVersion":"5.0.0","_nodeVersion":"8.0.0","_npmUser":{"name":"lukechilds","email":"lukechilds123@gmail.com"},"dist":{"integrity":"sha512-CRslSnR3z9MQ/8MNShNRQBwTzI7SI1GWWRQEc8+/dgbefXUoD7/S3pZQhF1YeIS3237owLg5IFkuo52X4nBAEA==","shasum":"b7b2fa85a083f5b4b467af31ee6a766ad99d9342","tarball":"http://registry-npm.ywwl.com/clone-response/download/clone-response-0.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC+cIV6/Y3bX1YrLVJZZPBW94lfpt+VWihbrwhqkS/m+wIhANPGW4n6NrSVDZD5+GLNsmGG7wNQQJ09gd5hR2sF/YQA"}],"size":2831,"noattachment":false,"key":"/clone-response/-/clone-response-0.2.1.tgz"},"maintainers":[{"name":"lukechilds","email":"lukechilds123@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/clone-response-0.2.1.tgz_1496460501457_0.03791434480808675"},"directories":{},"readme":"# clone-response\n\n> Clone a Node.js HTTP response stream\n\nReturns a new stream and copies over all properties and methods from the original response giving you a complete duplicate.\n\nThis is useful in situations where you need to consume the response stream but also want to pass an unconsumed stream somewhere else to be consumed later.\n\n## Install\n\n```sh\nnpm install clone-response\n```\n\n## Usage\n\n```js\nimport http from 'node:http';\nimport cloneResponse from 'clone-response';\n\nhttp.get('http://example.com', response => {\n\tconst clonedResponse = cloneResponse(response);\n\tresponse.pipe(process.stdout);\n\n\tsetImmediate(() => {\n\t\t// The response stream has already been consumed by the time this executes,\n\t\t// however the cloned response stream is still available.\n\t\tdoSomethingWithResponse(clonedResponse);\n\t});\n});\n```\n\nPlease bear in mind that the process of cloning a stream consumes it. However, you can consume a stream multiple times in the same tick, therefore allowing you to create multiple clones. For example:\n\n```js\nconst clone1 = cloneResponse(response);\nconst clone2 = cloneResponse(response);\n// The response can still be consumed in this tick but cannot be consumed if passed\n// into any async callbacks. clone1 and clone2 can be passed around and be\n// consumed in the future.\n```\n\n## API\n\n### cloneResponse(response)\n\nReturns a clone of the passed in response stream.\n\n#### response\n\nType: `Stream`\n\nA [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage) to clone.\n","publish_time":1496460501554,"_cnpm_publish_time":1496460501554,"dist-tags":{"latest":"2.0.0"}}