Write an EOT marker.
Write an ETB commit marker (stream mode), with an optional integrity payload. The payload may not contain control bytes — it is terminated by the next control code on read.
Optionalpayload: BuilderValueWrite a raw field value (for use within records when building fields individually).
Write a file/database scope.
Optionalfn: () => voidWrite a group/table scope with optional headers.
Optionalheaders: string[] | nullOptionalfn: () => voidWrite a standalone SOH header (e.g. for stream mode, where the header is appended and committed separately from the group).
Write a field whose value is a flat list (spec: "arrays are US-separated
values inside STX/ETX"): US, STX, the items separated by US, ETX.
Read back with Record#list.
Write a nested sub-structure.
Write a reference: one segment is ENQ + group name, more is a path (ENQ STX segments-joined-by-US ETX). Reference targets are names, so control bytes are rejected.
Write GS×N for document-mode depth.
Optionalfn: () => voidFinalize and return the buffer.
Builds C0DATA documents in compact form.
Names (file/group labels, headers, reference targets) are strings and reject control bytes. Values (record fields, list items, blocks, items, ETB payloads) are byte-transparent: pass a string for UTF-8 text or a Uint8Array for raw bytes; control bytes are DLE-escaped automatically.
Example: const buf = build(b => { b.file('mydb', () => { b.group('users', ['name', 'amount', 'type'], () => { b.record('Alice', '1502.30', 'DEPOSIT') b.record('Bob', '340.00', 'WITHDRAWAL') }) }) })