Skip to main content
Version: v0.0.2

Function: getAllSegmentValues()

getAllSegmentValues(segment, path, delimiters, emit?): readonly string[]

Return every repetition / component matching the dot-path. For a path with no [N] and no -N (e.g. "03"), returns every repetition's decoded element text. For a path with -N and no [N], returns each repetition's Nth component. With both [N] and -N specified, returns a single-element array (or empty if the path doesn't resolve). Every returned string is post-?-unescape.

Parameters

segment

X12Segment

path

string

delimiters

Delimiters

emit?

(w) => void

Returns

readonly string[]

Example

import { decodeSegment, getAllSegmentValues } from "@cosyte/x12";
const d = { element: "*", repetition: "^", component: ":", segment: "~" };
const seg = decodeSegment(
"HI*ABK:J45.50^ABF:I10",
d,
() => {},
{ segmentIndex: 0 },
);
getAllSegmentValues(seg, "01", d); // ["ABK:J45.50", "ABF:I10"]
getAllSegmentValues(seg, "01-1", d); // ["ABK", "ABF"]