Class Chunker<T>

Collects items up to countLimit, calling writer before sizeLimit would be exceeded.

Remarks

Always call onIdle when done to ensure that the last writer call is made.

Type Parameters

  • T

    Type of items to be chunked

Hierarchy

  • Chunker

Constructors

  • Collects items up to countLimit, calling writer before sizeLimit would be exceeded.

    Type Parameters

    • T

      Type of items to be chunked

    Parameters

    • options: IChunkerOptions<T>

      Chunker options

    Returns Chunker<T>

    Remarks

    Always call onIdle when done to ensure that the last writer call is made.

Properties

_backgroundWriter: Promise<void>
_errors: Errors = []
_iterableQueue: IterableQueue<T> = ...
_pendingItems: T[] = []
_pendingSize: number = 0
_writer: WriterFunc<T>

Accessors

  • get errors(): Errors
  • Accumulated errors from background flushes

    Returns Errors

  • get pendingCount(): number
  • Number of items pending

    Returns number

  • get pendingSize(): number
  • Sum of the user-defined size of all pending items

    Returns number

Methods

  • Adds an item to the pending queue, flushing the queue before adding the item if the new item would cause the item limit or size limit to be exceeded.

    Parameters

    • item: T

      Item to be added to the queue

    Returns Promise<void>

  • Calls writer for any pending items and clears pending items queue.

    Returns Promise<void>

    Result from writer function or undefined if no items pending

  • Wait for all background writes to finish. MUST be called before exit to ensure no lost writes.

    Returns Promise<void>

Generated using TypeDoc