Function: serializeAstmRecord()
serializeAstmRecord(
record,d?):string
Serialize a single ASTM record to its spec-clean wire text (no trailing terminator). Emits with the given delimiters, defaulting to the canonical set.
The header (H) is special-cased: its delimiter-definition field is emitted as
the literal declaration of d, never escaped, escaping it would corrupt the
very declaration a reader depends on, followed by any characters the modeled
declaration carried beyond the three a reader takes its roles from. Manufacturer
(M) and scientific (S) records are reproduced byte-identically from their
preserved rawLine when they are already in d, and re-encoded from their fields
when they are not, so their fields never collapse into one on the next read.
Parameters
record
The record to serialize.
d?
Delimiters = CANONICAL_DELIMITERS
The delimiters to emit against; defaults to H|\^&.
Returns
string
The record's wire text, terminator excluded.
Throws
AstmSerializeError when a component contains an unencodable CR/LF
(ASTM_EMIT_UNENCODABLE_VALUE), or when d fails one of the three conditions
readback requires (ASTM_EMIT_INVALID_DELIMITERS): necessary conditions, not
sufficient ones, so a set can pass them and still not reverse.
Example
import { serializeAstmRecord, parseAstmRecords } from "@cosyte/astm";
const msg = parseAstmRecords("H|\\^&\rR|1|^^^687|28.6|U/L||N||F\rL|1\r");
serializeAstmRecord(msg.records[1]!); // "R|1|^^^687|28.6|U/L||N||F"