@adviser/cement - v0.0.0
    Preparing search index...

    Interface ChunkyBaseOptions<T>

    Base configuration options shared by both sync and async chunky processing.

    interface ChunkyBaseOptions<T> {
        input: Iterable<T>;
        splitCondition(chunked: T[]): boolean;
        onCommit?(result: Result<void>, idx: number): void;
    }

    Type Parameters

    • T

      The type of items in the input iterable

    Index

    Properties

    Methods

    Properties

    input: Iterable<T>

    The input iterable to process. Can be an array, generator, or any iterable.

    Methods

    • Predicate function that determines when to commit a chunk. Called after each item is added to the current chunk. When it returns true, the chunk is committed and a new chunk starts.

      Parameters

      • chunked: T[]

        The current accumulated chunk

      Returns boolean

      true to commit the chunk, false to continue accumulating

      // Commit when chunk reaches 10 items
      splitCondition: (chunked) => chunked.length >= 10
    • Optional callback invoked after each commit completes (success or failure). Receives the result wrapped in a Result type and the commit index.

      Parameters

      • result: Result<void>

        Result.Ok() on success, Result.Err(error) on failure

      • idx: number

        Zero-based index of the commit (0 for first chunk, 1 for second, etc.)

      Returns void

      onCommit: (result, idx) => {
      if (result.isOk()) {
      console.log(`Chunk ${idx} committed successfully`)
      } else {
      console.error(`Chunk ${idx} failed:`, result.Err())
      }
      }