Class Channel<A>

Balances a push queue with a pull queue, also known as a dropping-buffer channel, since the queues are FIFO and can be set to be bounded, i.e., to drop the oldest enqueued values if the limit is exceeded. The channel is unbounded by default.

Type Parameters

  • A

Hierarchy

  • Channel

Implements

Constructors

  • Type Parameters

    • A

    Parameters

    • limit: number = Infinity

      Limit (bounds) after which the oldest buffered value is dropped.

    Returns Channel<A>

Properties

closed: boolean = false

Determines whether new values can be pushed or pulled

pullBuffer: Buffer<Deferred<IteratorResult<A, any>>>

Unresolved pulls waiting for results to be pushed

pushBuffer: Buffer<Unpushed<A>>

Pushed results waiting for pulls to resolve

fromDom: ((type, target, options?) => AsyncIterableIterator<Event | UIEvent | AnimationEvent | MouseEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | KeyboardEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent>) = ...

Type declaration

    • (type, target, options?): AsyncIterableIterator<Event | UIEvent | AnimationEvent | MouseEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | KeyboardEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent>
    • Parameters

      • type: keyof GlobalEventHandlersEventMap
      • target: Target<keyof GlobalEventHandlersEventMap, Listener<keyof GlobalEventHandlersEventMap>, boolean | AddEventListenerOptions>
      • Optional options: boolean | AddEventListenerOptions

      Returns AsyncIterableIterator<Event | UIEvent | AnimationEvent | MouseEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | KeyboardEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent>

fromEmitter: ((type, emitter) => AsyncIterableIterator<any>) = ...

Type declaration

    • (type, emitter): AsyncIterableIterator<any>
    • Parameters

      • type: string | symbol
      • emitter: EventEmitter

      Returns AsyncIterableIterator<any>

Methods

  • Push the next result value.

    Parameters

    • value: A

      Result

    • done: boolean = false

      If true, closes the balancer when this result is resolved

    Returns Promise<IteratorResult<A, any>>

    Throws

    Throws if the balancer is already closed

  • Closes the balancer; clears the queues and makes next only return doneResult.

    Parameters

    • Optional value: A

      The result value to be returned

    Returns Promise<IteratorResult<A, any>>

Generated using TypeDoc