Skip to main content
Version: v0.0.3

Interface: FrameReaderOptions

Options for FrameReader.

All tolerance opts default to false, every framing deviation throws unless explicitly enabled. Server-level defaults (allowFsOnly, allowLfAfterFs, allowLeadingWhitespace) are applied by the server when constructing readers.

Example

const opts: FrameReaderOptions = {
onFrame: (payload, byteOffset, warnings) => process(payload, byteOffset, warnings),
onWarning: (w) => logger.warn(w),
maxFrameSizeBytes: 4 * 1024 * 1024, // 4 MiB limit
allowFsOnly: true,
allowLfAfterFs: true,
};

Properties

allowFsOnly?

optional allowFsOnly?: boolean

Tolerate FS without trailing CR; emits MLLP_FS_WITHOUT_CR.


allowLeadingWhitespace?

optional allowLeadingWhitespace?: boolean

Tolerate SP/TAB/LF/CR before VT; emits MLLP_LEADING_WHITESPACE.


allowLfAfterFs?

optional allowLfAfterFs?: boolean

Tolerate FS+LF instead of FS+CR; emits MLLP_LF_AFTER_FS.


allowMissingLeadingVt?

optional allowMissingLeadingVt?: boolean

Tolerate missing leading VT; emits MLLP_MISSING_LEADING_VT.


maxFrameSizeBytes?

optional maxFrameSizeBytes?: number

Maximum accumulated payload bytes before MllpFramingError('MLLP_FRAME_TOO_LARGE'). Default: 16 MiB (DoS prevention).


onFrame

onFrame: (payload, byteOffset, warnings) => void

Called synchronously during push() for each complete MLLP payload.

Parameters

payload

Buffer

Raw MLLP payload bytes (framing stripped).

byteOffset

number

Stream byte offset of the VT byte that opened this frame. Monotonic across the connection lifetime; reset to 0 by reset().

warnings

readonly MllpWarning[]

Framing warnings emitted during decoding of this specific frame. Empty array when no tolerance deviations were detected.

Returns

void


onWarning?

optional onWarning?: (w) => void

Called for each tolerated framing deviation. Wrapped in try/catch. A throwing handler will not corrupt FSM state.

Parameters

w

MllpWarning

Returns

void


strict?

optional strict?: boolean

When true, escalates the following tolerances to thrown MllpFramingError even if individual opt-ins (allowFsOnly, allowLfAfterFs, allowMissingLeadingVt, allowLeadingWhitespace) are enabled:

  • MLLP_MISSING_LEADING_VT
  • MLLP_FS_WITHOUT_CR
  • MLLP_LF_AFTER_FS
  • MLLP_LEADING_WHITESPACE (leading whitespace escalates as MLLP_MISSING_LEADING_VT)

MLLP_EMPTY_PAYLOAD and MLLP_TRAILING_BYTES remain warnings even in strict mode.

Example

// Hardened enforcement, no tolerance, all violations throw
const reader = new FrameReader({ onFrame: fn, strict: true });