MCPcopy
hub / github.com/sindresorhus/got / proxyEvents

Function proxyEvents

source/core/utils/proxy-events.ts:3–20  ·  view source on GitHub ↗
(from: EventEmitter, to: EventEmitter, events: readonly string[])

Source from the content-addressed store, hash-verified

1import type {EventEmitter} from 'node:events';
2
3export default function proxyEvents(from: EventEmitter, to: EventEmitter, events: readonly string[]): () => void {
4 const eventFunctions = new Map<string, (...arguments_: unknown[]) => void>();
5
6 for (const event of events) {
7 const eventFunction = (...arguments_: unknown[]) => {
8 to.emit(event, ...arguments_);
9 };
10
11 eventFunctions.set(event, eventFunction);
12 from.on(event, eventFunction);
13 }
14
15 return () => {
16 for (const [event, eventFunction] of eventFunctions) {
17 from.off(event, eventFunction);
18 }
19 };
20}

Callers 2

_onRequestMethod · 0.85
makeRequestFunction · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…