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

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/msw/src/core/utils/internal/pipeEvents.ts