mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-09-03 03:20:24 +00:00
- slim/slim: ^3.1 - symfony/expression-language: ^3.4 - fxp/composer-asset-plugin: ~1.3 - bower-asset/vue: ^2.5 - bower-asset/vue-resource: ^1.5
33 lines
810 B
JavaScript
33 lines
810 B
JavaScript
'use strict';
|
|
|
|
// We define these manually to ensure they're always copied
|
|
// even if they would move up the prototype chain
|
|
// https://nodejs.org/api/http.html#http_class_http_incomingmessage
|
|
const knownProps = [
|
|
'destroy',
|
|
'setTimeout',
|
|
'socket',
|
|
'headers',
|
|
'trailers',
|
|
'rawHeaders',
|
|
'statusCode',
|
|
'httpVersion',
|
|
'httpVersionMinor',
|
|
'httpVersionMajor',
|
|
'rawTrailers',
|
|
'statusMessage'
|
|
];
|
|
|
|
module.exports = (fromStream, toStream) => {
|
|
const toProps = Object.keys(toStream);
|
|
const fromProps = new Set(Object.keys(fromStream).concat(knownProps));
|
|
|
|
for (const prop of fromProps) {
|
|
// Don't overwrite existing properties
|
|
if (toProps.indexOf(prop) !== -1) {
|
|
continue;
|
|
}
|
|
|
|
toStream[prop] = typeof fromStream[prop] === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop];
|
|
}
|
|
};
|