Function: commentsFor()
commentsFor(
msg,parent): readonlyCommentRecord[]
The comment (C) records attached to a given parent record, in wire order.
Unlike the other extractors this works on any stream, single- or multi-message: the
parent record it is handed already names the message, so there is nothing to disambiguate.
Returns the comments whose parentIndex is that record's recordIndex, so a
comment carrying (e.g.) QC context is read against the record it modifies:
never floated to the wrong one.
Parameters
msg
A parsed message.
parent
The H/P/O/R record whose comments to collect.
Returns
readonly CommentRecord[]
The attached comment records (possibly empty).
Example
import { parseAstmRecords, results, commentsFor } from "@cosyte/astm";
const msg = parseAstmRecords("H|\\^&\rR|1|^^^687|5|U/L||||F\rC|1|I|checked|G\rL|1\r");
commentsFor(msg, results(msg)[0]!)[0]?.text; // "checked"