Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

index.js 758B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. // We define these manually to ensure they're always copied
  3. // even if they would move up the prototype chain
  4. // https://nodejs.org/api/http.html#http_class_http_incomingmessage
  5. const knownProps = [
  6. 'destroy',
  7. 'setTimeout',
  8. 'socket',
  9. 'headers',
  10. 'trailers',
  11. 'rawHeaders',
  12. 'statusCode',
  13. 'httpVersion',
  14. 'httpVersionMinor',
  15. 'httpVersionMajor',
  16. 'rawTrailers',
  17. 'statusMessage'
  18. ];
  19. module.exports = (fromStream, toStream) => {
  20. const fromProps = new Set(Object.keys(fromStream).concat(knownProps));
  21. for (const prop of fromProps) {
  22. // Don't overwrite existing properties
  23. if (prop in toStream) {
  24. continue;
  25. }
  26. toStream[prop] = typeof fromStream[prop] === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop];
  27. }
  28. };