Worker for processing messages in batches with throttling

Type Parameters

  • T

    Type of messages to process

Constructors

Properties

buffer: T[] = []
handlers: Map<any, (x: T) => void[]> = ...
opts: WorkerOpts<T> = {}

Methods

  • Adds a handler for all messages

    Parameters

    • handler: (message: T) => void

      Function to process all messages

    Returns void

  • Adds a handler for messages with specific key

    Parameters

    • k: any

      Key to handle

    • handler: (message: T) => void

      Function to process matching messages

    Returns void

  • Removes all pending messages from the queue

    Returns void

  • Pauses message processing

    Returns void

  • Adds a message to the processing queue

    Parameters

    • message: T

      Message to process

    Returns void

  • Resumes message processing

    Returns void