• File: index.js
  • Full Path: /var/www/nodejs/daily_store_reports_nodejs/node_modules/clone-response/src/index.js
  • Date Modified: 02/04/2023 9:31 PM
  • File size: 401 bytes
  • MIME-type: text/plain
  • Charset: utf-8
'use strict';

const PassThrough = require('stream').PassThrough;
const mimicResponse = require('mimic-response');

const cloneResponse = response => {
	if (!(response && response.pipe)) {
		throw new TypeError('Parameter `response` must be a response stream.');
	}

	const clone = new PassThrough();
	mimicResponse(response, clone);

	return response.pipe(clone);
};

module.exports = cloneResponse;