{"name":"clone-response","version":"1.0.3","description":"Clone a Node.js HTTP response stream","main":"src/index.js","scripts":{"test":"xo && nyc ava","coverage":"nyc report --reporter=text-lcov | coveralls"},"funding":"https://github.com/sponsors/sindresorhus","xo":{"extends":"xo-lukechilds"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/clone-response.git"},"keywords":["clone","duplicate","copy","response","HTTP","stream"],"author":{"name":"Luke Childs","email":"lukechilds123@gmail.com","url":"http://lukechilds.co.uk"},"license":"MIT","dependencies":{"mimic-response":"^1.0.0"},"devDependencies":{"ava":"^0.22.0","coveralls":"^2.13.1","create-test-server":"^2.0.1","eslint-config-xo-lukechilds":"^1.0.0","get-stream":"^3.0.0","nyc":"^11.0.2","pify":"^3.0.0","xo":"^0.19.0"},"gitHead":"b113fa538f5b9c5520e1adfdfa8d73afe437c700","bugs":{"url":"https://github.com/sindresorhus/clone-response/issues"},"homepage":"https://github.com/sindresorhus/clone-response#readme","_id":"clone-response@1.0.3","_nodeVersion":"14.19.3","_npmVersion":"8.3.2","dist":{"integrity":"sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==","shasum":"af2032aa47816399cf5f0a1d0db902f517abb8c3","tarball":"http://registry-npm.ywwl.com/clone-response/download/clone-response-1.0.3.tgz","fileCount":4,"unpackedSize":4526,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDetbaU/AEVbGF09LarTHOFxGeEy63A1bQUoLmjqjBS6gIhAKyHGSopE02tGcuNO+TckqSg3fNqz8IgzMSk/Rod2gcz"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi1CQdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpn6BAAmBVohVLL/R054d9YXqstR763hBGCKDd6CB52GWySEp4hCRjT\r\n2yf6GCVKwSZBtj0AuwpzMpT5yoUCZOGZYK+NBFGA5hizGTR/V/XrOS5/NiXu\r\n+OdyQDNA2rJFUNPJgc7ujvur6IDKvRhnL/dNWZGcGURN5gkpJVTxcJ8h3muu\r\nBsf5X8cS5X0CNIjFz8zZNMnreGiRus9iEc/LfCfJjVt7Fmy1pwzoNrjnGhzf\r\nZgQ5mBm8Lub6eUQ3fUkMB+2VOWwwmYZc/ezI9I0e1vnxKbpZK8xGuYaZ97JW\r\n7l9+BEVQDIXQ5K65subdUk4JjSzEsEYfBTQRSDcNIYdrnLRHDZ+aaipmuWJd\r\nL/F3J5vroww/+a1JShHgK0WXplpoa6HtQu71rBAPyl6w07ghilb9VihiPeUW\r\n1XvUHq2SFgVAQ9qE+hcX8lI3+8ElNDt6QOMiMqmcuwzuC6CLbKwifEUobgx9\r\nPBILOCQaSrAjTtTFAgeK8Qt7D3QdPOMBOMqJ2FtIZhHDWkrA53hKcqYEQYf7\r\nRQ6gHCEvnSQRPsgw2wWKrpIUHWegGe/20tFPKh29WcahAa4AwXbVUkGmosP+\r\nvfXhkn4J2BEXymAGrIx/il3MbB3rY+Fi0mkXL3nWQAykKjTnv9MspyT51pFw\r\n8KVqtwiGKJZG6h9tYq2hEF8IUey1ald0lrA=\r\n=siN8\r\n-----END PGP SIGNATURE-----\r\n","size":2231,"noattachment":false,"key":"/clone-response/-/clone-response-1.0.3.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"},{"name":"lukechilds","email":"lukechilds123@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/clone-response_1.0.3_1658070045760_0.7587340926053368"},"_hasShrinkwrap":false,"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":1658070045903,"_cnpm_publish_time":1658070045903,"dist-tags":{"latest":"2.0.0"}}