/**
 * Base class for stream sinks.
 *
 * A Sink is a terminal consumer of an async iterable. It accepts
 * elements via `_accept()`, then produces a final accumulated result
 * via `_finalize()`. Sinks do not yield values — they end the pipeline.
 *
 * Examples: TreeAssemblerSink accumulates [path, oid] entries and
 * calls writeTree() in finalize(). ArraySink collects all items.
 */
export default class Sink<T, R> {
    /**
     * Consumes an entire async iterable and returns the accumulated result.
     *
     * Subclasses implement `_accept(item)` for per-element processing and
     * `_finalize()` for the terminal result. The default `consume()` loop
     * handles iteration, error propagation, and finalization.
     */
    consume(source: AsyncIterable<T>): Promise<R>;
    /**
     * Accepts a single element from the stream.
     *
     * Override this in subclasses to process each element.
     */
    protected _accept(_item: T): void | Promise<void>;
    /**
     * Produces the final accumulated result after all elements are consumed.
     *
     * Override this in subclasses to return the terminal value.
     */
    protected _finalize(): R | Promise<R>;
}
