Skip to main content
Version: v0.0.2

Interface: X12Segment

Immutable decoded X12 segment. elements is 1-indexed: elements[0] is the segment id placeholder (matching "./types.js".IsaSegment, GsSegment, etc. - every typed segment in the envelope follows the same 1-indexed shape so consumers learn one rule and never have to recall whether a particular accessor offsets by one). raw preserves the exact segment text from input (terminator stripped) so a byte-exact round-trip survives even when downstream stages mutate the model.

Element values are stored RAW (pre-?-unescape). Reads via getSegmentValue apply unescapeRelease on demand - this keeps round-trip byte-exact while still letting helpers receive spec-compliant logical values.

Example

import type { X12Segment } from "@cosyte/x12";
declare const seg: X12Segment;
seg.id; // "NM1"
seg.elements[3]; // raw text of NM1-03 (post-element-split, pre-?-unescape)

Properties

elements

readonly elements: readonly string[]


id

readonly id: string


raw

readonly raw: string