Sha256: 038b3b776c334641e02b89baa5597579563f9a5bb55d3addbfe6ad76870c98d1
Contents?: true
Size: 645 Bytes
Versions: 26
Compression:
Stored size: 645 Bytes
Contents
import { Emitter, EventMap } from 'strict-event-emitter' /** * Pipes all emitted events from one emitter to another. */ export function pipeEvents<Events extends EventMap>( source: Emitter<Events>, destination: Emitter<Events>, ): void { const rawEmit: typeof source.emit & { _isPiped?: boolean } = source.emit if (rawEmit._isPiped) { return } const sourceEmit: typeof source.emit & { _isPiped?: boolean } = function sourceEmit(this: typeof source, event, ...data) { destination.emit(event, ...data) return rawEmit.call(this, event, ...data) } sourceEmit._isPiped = true source.emit = sourceEmit }
Version data entries
26 entries across 26 versions & 1 rubygems