friendica-addons/advancedcontentfilter/vendor/npm-asset/mimic-response/index.js
Hypolite Petovan 20862be7d0 [advancedcontentfilter] Add Composer dependencies
- 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
2018-04-16 22:11:51 -04:00

34 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];
}
};