Stateful chunker is just like regular Chunker execpt it also carries mutable state that it is free to update as needed. It is adviced to use regural Chunker and only resort to this when chunking logic may depend on previously seen bytes.

Type Parameters

  • T

Hierarchy

Properties

Methods

Properties

context: T

Context used by the chunker. It usually represents chunker configuration like max, min chunk size etc. Usually chunker implementation library will provide utility function to initalize a context.

name?: string
type: "Stateful"

Methods

  • Chunker takes a context:T object, buffer containing bytes to be chunked. Chunker is expected to return array of chunk byte lengths (from the start of the buffer). If returned array is empty that signifies that buffer contains no valid chunks.

    Note: Consumer of the chunker is responsible for dealing with remaining bytes in the buffer, that is unless end is true signalling chunker that end of the stream is reached.

    Parameters

    • context: T
    • buffer: Chunk
    • Optional end: boolean

    Returns Iterable<number>

Generated using TypeDoc