Function: parseFramedAstm()
parseFramedAstm(
bytes,options?):FramedAstmResult
Decode a framed ASTM byte stream and parse its reassembled records in one call.
Only trusted, contiguous frames are reassembled (a bad-checksum frame, a
sequence gap, or an unterminated frame is surfaced in frames/frameWarnings
but never fed to the record parser), so the parsed message reflects only bytes
the framing layer vouched for.
Parameters
bytes
Uint8Array
The framed byte stream.
options?
FrameOptions & AstmParseOptions = {}
Frame decode options and record parse options (both layers
honor a shared strict).
Returns
The parsed message plus the frame-layer detail.
Throws
AstmParseError EMPTY_INPUT when the stream is empty, or when no
trusted records could be reassembled (nothing to parse).
Throws
AstmFrameStrictError / AstmStrictError in strict mode on
a frame or record deviation, respectively.
Example
import { parseFramedAstm } from "@cosyte/astm";
// A single final frame carrying "H|\^&\r" - checksum "E5" over FN..ETX (mod 256).
const bytes = new Uint8Array([
0x02, 0x31, 0x48, 0x7c, 0x5c, 0x5e, 0x26, 0x0d, 0x03, 0x45, 0x35, 0x0d, 0x0a,
]);
const { message, frames } = parseFramedAstm(bytes);
message.header.delimiters.field; // "|"
frames.length; // 1