got-cjs
Version:
Human-friendly and powerful HTTP request library for Node.js
19 lines (18 loc) • 560 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function proxyEvents(from, to, events) {
const eventFunctions = {};
for (const event of events) {
const eventFunction = (...args) => {
to.emit(event, ...args);
};
eventFunctions[event] = eventFunction;
from.on(event, eventFunction);
}
return () => {
for (const [event, eventFunction] of Object.entries(eventFunctions)) {
from.off(event, eventFunction);
}
};
}
exports.default = proxyEvents;