{"name":"clone-response","version":"2.0.0","description":"Clone a Node.js HTTP response stream","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/clone-response.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Luke Childs","email":"lukechilds123@gmail.com","url":"https://lukechilds.co.uk"},"type":"module","exports":"./index.js","engines":{"node":">=14.16"},"scripts":{"test":"xo && ava"},"keywords":["clone","response","duplicate","copy","http","stream"],"dependencies":{"mimic-response":"^4.0.0"},"devDependencies":{"ava":"^4.3.1","create-test-server":"^3.0.1","get-stream":"^6.0.1","pify":"^6.0.0","xo":"^0.50.0"},"gitHead":"3c2392df0d6a7811ef30e4d31c981db3080d9d56","bugs":{"url":"https://github.com/sindresorhus/clone-response/issues"},"homepage":"https://github.com/sindresorhus/clone-response#readme","_id":"clone-response@2.0.0","_nodeVersion":"14.19.3","_npmVersion":"8.3.2","dist":{"integrity":"sha512-2jbaEcptYA32VbtJw/ucElFsFNVPmF+fkXWsH+GgjWX7fZWGosmqXxzAf+5nIeqAzg2HKpHu0zFXGhaRWkQdNw==","shasum":"6978655600cb6f0bb99ca5f10e7fb0c19ecc56bc","tarball":"http://registry-npm.ywwl.com/clone-response/download/clone-response-2.0.0.tgz","fileCount":4,"unpackedSize":3869,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDKNXJa6LqWC6cvvBZlcUuSS8TQgn5zWkC4Fzn4Q3Z3dQIgM1rfWNrslofqPy5aD/XdnO69lxHo/Xkwkd5X9HEJSHU="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi1CcNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqmfQ/+Pcf2cGqITLv+8csXhr0AWO3axOkzjgtxCVzNpWNAVI6/g0DC\r\ncbUhvMml1nO+tJUZGYobZAftweeGNBNe5VdLogemSGL7QoUskPpm9S/u5Hod\r\ne1H6nUwdyZkb11STqt5lRhpWgd7IIiGzsu/3tMMiE3+XqPug9fVcEGxL1dBJ\r\nPbDGQUHQlWorL8xe1HIHqm24UNWiSWU5U4+fTtFbVTKUbbQ+PsjEh7If+xZI\r\nd/s4+j+YhOepiXtEKQ1iVoPy0+llybmnIzQnuNJlu/kZHgVkdao2l4NgsLps\r\nVgeN0DpIUoo3iVPU9QczEYTuxa0POokp/X4lLxGmw5GkOZ2xBNhRWLkmYVYR\r\nrXetVW4TuaI/bBRtW3xgaETxOC28uEKmEXBLtHQQ1oZ1VuUECCsjWGtd+Wk8\r\nE381C6o8C4sZYPrVjRy+9EGZHT6ezlFnh7ZOh0yFS0YgJujDezjNYc7YsU30\r\nl/Cu6SEwThicB5QemTTJqjFZRP2z33nuU0eV3c16Y2D9IkI9KLX/9wphjZy9\r\n+ag4uZ6CvstO1HVhEH2glvOGmHOks24Owp1tGKpigccILTLz9PtkM0BxVDc+\r\nXpU4Ij70UFWdm1suV7Ck9dnL17wuZobhE5X4w4/J9tgEf1kVIbRqGil0HQnB\r\njffI3P/CYqz0t7SBwXGwJ1a8ZYHvQRfH1UA=\r\n=FCHf\r\n-----END PGP SIGNATURE-----\r\n","size":2015,"noattachment":false,"key":"/clone-response/-/clone-response-2.0.0.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_2.0.0_1658070796968_0.5743072080081504"},"_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":1658070797135,"_cnpm_publish_time":1658070797135,"dist-tags":{"latest":"2.0.0"}}