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

    Function processStream

    • Processes a ReadableStream with a callback function and optional context.

      Similar to consumeStream but doesn't collect results - just processes each chunk sequentially. Useful for side effects like logging, writing to files, etc.

      Type Parameters

      • E

        Stream element type

      • CTX = object

        Context type passed to callback

      Parameters

      • stream: ReadableStream<E>

        The ReadableStream to process

      • cb: (msg: E, ctx: CTX) => void | Promise<void>

        Callback function applied to each chunk (receives chunk and context)

      • ctx: CTX = ...

        Optional context object passed to each callback invocation

      Returns Promise<void>

      Promise that resolves when stream is fully processed

      await processStream(logStream, (entry, ctx) => {
      ctx.count++;
      console.log(`[${ctx.count}]`, entry);
      }, { count: 0 });