Function: decodeAstmFrames()
decodeAstmFrames(
bytes,options?):DecodeAstmFramesResult
Decode a framed ASTM byte stream into frames + reassembled record bytes.
Bytes outside a frame (before the first STX, or between a frame's trailing
LF and the next STX) are skipped: in ASTM they are low-level transfer
control (ENQ/ACK/NAK/EOT), never record content, so skipping them is
not data loss.
Parameters
bytes
Uint8Array
The framed byte stream.
options?
FrameOptions = {}
Decode options; lenient unless strict is set.
Returns
The decoded frames, the reassembled trusted record bytes, and any warnings.
Throws
AstmParseError with EMPTY_INPUT when bytes is empty (both modes).
Throws
AstmFrameStrictError when strict is set and any deviation occurred.
Example
import { decodeAstmFrames } from "@cosyte/astm";
// One final frame carrying the record text "R|1|" - checksum "AF" over FN..ETX (mod 256).
const bytes = new Uint8Array([0x02, 0x31, 0x52, 0x7c, 0x31, 0x7c, 0x03, 0x41, 0x46, 0x0d, 0x0a]);
const { records, frames } = decodeAstmFrames(bytes);
frames[0]?.frameNumber; // 1
records.length; // 1