edgeport - v1.0.6
    Preparing search index...

    Interface FramedReader

    Reads exact byte counts and delimited frames from a byte stream, hiding TCP chunking.

    Reads are buffered: a single underlying chunk may satisfy several readN calls, and a single readN may consume several chunks. Only one underlying read is ever in flight, so a readN that rejects with TimeoutError leaves any late-arriving bytes in the buffer for the next call rather than dropping them.

    1.0.0

    interface FramedReader {
        cancel(): Promise<void>;
        peek(n: number, timeoutMs?: number): Promise<Uint8Array<ArrayBufferLike>>;
        readLine(timeoutMs?: number): Promise<string>;
        readN(n: number, timeoutMs?: number): Promise<Uint8Array<ArrayBufferLike>>;
        readUntil(
            delim: Uint8Array,
            max?: number,
            timeoutMs?: number,
        ): Promise<Uint8Array<ArrayBufferLike>>;
    }

    Implemented by

    Index
    • Releases the underlying reader and cancels the stream.

      Returns Promise<void>

    • Returns the next n bytes without consuming them.

      Parameters

      • n: number

        Number of bytes to inspect.

      • OptionaltimeoutMs: number

        Optional deadline.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      A copy of the next n bytes.

    • Reads one line terminated by LF, returning it decoded as UTF-8 with the trailing CRLF or LF stripped. Suitable for the text line protocols (SMTP, IMAP, POP3).

      Parameters

      • OptionaltimeoutMs: number

        Optional deadline.

      Returns Promise<string>

      The line without its terminator.

    • Reads and consumes exactly n bytes.

      Parameters

      • n: number

        Number of bytes to read.

      • OptionaltimeoutMs: number

        Optional deadline; rejects with TimeoutError if exceeded.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The n bytes read.

      If the stream ends before n bytes are available.

      If timeoutMs elapses first.

    • Reads and consumes bytes up to and including the first occurrence of delim.

      Parameters

      • delim: Uint8Array

        The delimiter to scan for.

      • Optionalmax: number

        Optional cap on bytes scanned before failing (guards against a peer that never sends the delimiter).

      • OptionaltimeoutMs: number

        Optional deadline.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      Everything up to and including delim.

      If the stream ends first, or max is exceeded.

      If timeoutMs elapses first.