Skip to content

Configuration: File formatter

Madeline Kahn edited this page Dec 30, 2025 · 1 revision

You can pass a configuration object (CDIFFileOptions) to CDIF.serializeFile() to customize the behavior of the file formatter. Most values are optional, and will fall back to a default value if they are omitted or undefined. The available options in CDIFFileOptions are as follows:

addHeader

addHeader?: boolean;

Whether to prepend the # cDIF directive at the start of the file.

Default value: if cdifVersionString is supplied then true, else false

cdifVersionString

cdifVersionString?: string;

cDIF version string to use in the # cDIF directive.

Required if addHeader is true, otherwise ignored

addFinalSemicolon

addFinalSemicolon?: boolean;

Whether to append a semicolon at the end of the data value.

Default value: false

allowUnexpectedVersionString

allowUnexpectedVersionString?: boolean;

If true, cdifVersionString will not be validated. If false, an error will be thrown if cdifVersionString is invalid or does not match the cDIF version in use.

Default value: false

Clone this wiki locally