Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # clone-response
  2. > Clone a Node.js HTTP response stream
  3. [![Build Status](https://travis-ci.org/lukechilds/clone-response.svg?branch=master)](https://travis-ci.org/lukechilds/clone-response)
  4. [![Coverage Status](https://coveralls.io/repos/github/lukechilds/clone-response/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/clone-response?branch=master)
  5. [![npm](https://img.shields.io/npm/dm/clone-response.svg)](https://www.npmjs.com/package/clone-response)
  6. [![npm](https://img.shields.io/npm/v/clone-response.svg)](https://www.npmjs.com/package/clone-response)
  7. Returns a new stream and copies over all properties and methods from the original response giving you a complete duplicate.
  8. This 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.
  9. ## Install
  10. ```shell
  11. npm install --save clone-response
  12. ```
  13. ## Usage
  14. ```js
  15. const http = require('http');
  16. const cloneResponse = require('clone-response');
  17. http.get('http://example.com', response => {
  18. const clonedResponse = cloneResponse(response);
  19. response.pipe(process.stdout);
  20. setImmediate(() => {
  21. // The response stream has already been consumed by the time this executes,
  22. // however the cloned response stream is still available.
  23. doSomethingWithResponse(clonedResponse);
  24. });
  25. });
  26. ```
  27. Please 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:
  28. ```js
  29. const clone1 = cloneResponse(response);
  30. const clone2 = cloneResponse(response);
  31. // response can still be consumed in this tick but cannot be consumed if passed
  32. // into any async callbacks. clone1 and clone2 can be passed around and be
  33. // consumed in the future.
  34. ```
  35. ## API
  36. ### cloneResponse(response)
  37. Returns a clone of the passed in response.
  38. #### response
  39. Type: `stream`
  40. A [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage) to clone.
  41. ## License
  42. MIT © Luke Childs