Function: getSegmentValue()
getSegmentValue(
segment,path,delimiters,emit?):string|undefined
Resolve a dot-path against a decoded X12Segment and return the
decoded leaf value (post-?-unescape) or undefined if the path does
not resolve (missing element, out-of-range repetition, out-of-range
component). Throws TypeError only when path itself is malformed.
Optional emit collects any dangling-release warnings discovered on the
read path; pass a no-op to silently decode.
Parameters
segment
path
string
delimiters
emit?
(w) => void
Returns
string | undefined
Example
import { decodeSegment, getSegmentValue } from "@cosyte/x12";
const d = { element: "*", repetition: "^", component: ":", segment: "~" };
const seg = decodeSegment(
"HI*ABK:J45.50*ABF:I10",
d,
() => {},
{ segmentIndex: 0 },
);
getSegmentValue(seg, "01-1", d); // "ABK"
getSegmentValue(seg, "01-2", d); // "J45.50"
getSegmentValue(seg, "02-1", d); // "ABF"