UNPKG

@zkochan/pnpm

Version:

Fast, disk space efficient package manager

110 lines (109 loc) 5 kB
{ "_args": [ [ { "raw": "clone-response@1.0.2", "scope": null, "escapedName": "clone-response", "name": "clone-response", "rawSpec": "1.0.2", "spec": "1.0.2", "type": "version" }, "/home/zkochan/src/pnpm/packages/pnpm/node_modules/cacheable-request" ] ], "_from": "clone-response@1.0.2", "_id": "clone-response@1.0.2", "_inCache": true, "_location": "/clone-response", "_nodeVersion": "8.4.0", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/clone-response-1.0.2.tgz_1502988274674_0.8035625964403152" }, "_npmUser": { "name": "lukechilds", "email": "lukechilds123@gmail.com" }, "_npmVersion": "4.6.1", "_phantomChildren": {}, "_requested": { "raw": "clone-response@1.0.2", "scope": null, "escapedName": "clone-response", "name": "clone-response", "rawSpec": "1.0.2", "spec": "1.0.2", "type": "version" }, "_requiredBy": [ "/cacheable-request" ], "_resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", "_shasum": "d1dc973920314df67fbeb94223b4ee350239e96b", "_shrinkwrap": null, "_spec": "clone-response@1.0.2", "_where": "/home/zkochan/src/pnpm/packages/pnpm/node_modules/cacheable-request", "author": { "name": "Luke Childs", "email": "lukechilds123@gmail.com", "url": "http://lukechilds.co.uk" }, "bugs": { "url": "https://github.com/lukechilds/clone-response/issues" }, "dependencies": { "mimic-response": "^1.0.0" }, "description": "Clone a Node.js HTTP response stream", "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" }, "directories": {}, "dist": { "shasum": "d1dc973920314df67fbeb94223b4ee350239e96b", "tarball": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz" }, "gitHead": "857094916c5393a7ce78838a4e447fa944263cca", "homepage": "https://github.com/lukechilds/clone-response", "keywords": [ "clone", "duplicate", "copy", "response", "HTTP", "stream" ], "license": "MIT", "main": "src/index.js", "maintainers": [ { "name": "lukechilds", "email": "lukechilds123@gmail.com" } ], "name": "clone-response", "optionalDependencies": {}, "readme": "# clone-response\n\n> Clone a Node.js HTTP response stream\n\n[![Build Status](https://travis-ci.org/lukechilds/clone-response.svg?branch=master)](https://travis-ci.org/lukechilds/clone-response)\n[![Coverage Status](https://coveralls.io/repos/github/lukechilds/clone-response/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/clone-response?branch=master)\n[![npm](https://img.shields.io/npm/dm/clone-response.svg)](https://www.npmjs.com/package/clone-response)\n[![npm](https://img.shields.io/npm/v/clone-response.svg)](https://www.npmjs.com/package/clone-response)\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```shell\nnpm install --save clone-response\n```\n\n## Usage\n\n```js\nconst http = require('http');\nconst cloneResponse = require('clone-response');\n\nhttp.get('http://example.com', response => {\n const clonedResponse = cloneResponse(response);\n response.pipe(process.stdout);\n\n setImmediate(() => {\n // The response stream has already been consumed by the time this executes,\n // however the cloned response stream is still available.\n doSomethingWithResponse(clonedResponse);\n });\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. e.g:\n\n```js\nconst clone1 = cloneResponse(response);\nconst clone2 = cloneResponse(response);\n// 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.\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\n## License\n\nMIT © Luke Childs\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/lukechilds/clone-response.git" }, "scripts": { "coverage": "nyc report --reporter=text-lcov | coveralls", "test": "xo && nyc ava" }, "version": "1.0.2", "xo": { "extends": "xo-lukechilds" } }