Grounds
    Preparing search index...

    Function createDecoderStream

    • Creates a TransformStream for decoding bytes to Relish values.

      Implements the Web Streams API for use with ReadableStream/WritableStream. Buffers incomplete frames across chunks.

      Returns TransformStream<Uint8Array<ArrayBufferLike>, DecodedValue>

      TransformStream<Uint8Array, DecodedValue>

      Web Streams pipeline:

      import { createDecoderStream } from '@grounds/stream';

      const decoder = createDecoderStream();

      const bytesStream = new ReadableStream({
      async start(controller) {
      controller.enqueue(new Uint8Array([0x02, 0x2a])); // U8(42)
      controller.close();
      }
      });

      const valuesStream = bytesStream.pipeThrough(decoder);

      for await (const value of valuesStream) {
      console.log('Decoded:', value);
      }

      Maintains internal buffer for frame boundaries. Decoding errors terminate the stream. For Result-based error handling, use decodeIterable.