Function: serializeFramedAstm()
serializeFramedAstm(
input,options?):Uint8Array
Serialize an ASTM message (or a bare record list) and frame it into a spec-clean byte stream in one call - the inverse of parseFramedAstm, composing the two emit layers at the edge.
Each record is serialized to spec-clean, CR-terminated wire text (canonical
delimiters, embedded delimiters re-escaped) and then framed independently
(one record per ETX-closed frame run), so the framing exactly mirrors what
decodeAstmFrames reassembles: parseFramedAstm(serializeFramedAstm(msg))
yields an equal message.
Parameters
input
AstmMessage | readonly AstmRecord[]
A parsed AstmMessage or a list of AstmRecords.
options?
ComposeFramesOptions = {}
Frame-encode options.
Returns
Uint8Array
The framed byte stream.
Throws
AstmSerializeError when a value contains an unencodable CR/LF.
Throws
AstmFrameEncodeError when there are no records to frame.
Example
import { parseAstmRecords, serializeFramedAstm, parseFramedAstm } from "@cosyte/astm";
const msg = parseAstmRecords("H|\\^&\rR|1|^^^687|28.6|U/L||N||F\rL|1\r");
const bytes = serializeFramedAstm(msg);
parseFramedAstm(bytes).message.records.length; // 3