Skip to main content
Version: v0.0.2

Function: setDefaultProfile()

setDefaultProfile(profile): void

Register a process-scoped default profile. parseX12(raw) (no explicit profile arg) consults getDefaultProfile() and attaches the returned profile to the result. Pass null (or undefined) to clear.

Explicit args ALWAYS win - parseX12(raw, { profile: myProfile }) uses myProfile regardless of the default; parseX12(raw, { profile: null }) opts out of the default for a single call without changing the registered default.

Test hygiene: the only mutable module-scoped state in the library. Tests that call this MUST clean up in afterEach (setDefaultProfile(null)).

Parameters

profile

X12Profile | null

Returns

void

Example

import { setDefaultProfile, getDefaultProfile, profiles, parseX12 } from "@cosyte/x12";
setDefaultProfile(profiles.availity);
const ix = parseX12(raw);
ix.profile?.name; // "availity"
setDefaultProfile(null); // clear (or in test teardown)