Skip to main content
Version: v0.0.4

Function: fmtFormat()

fmtFormat(format, bytes): Promise<FmtResult>

Canonically re-serialize one input of format via the wrapped library's spec-clean serializer. The CLI never re-canonicalizes on its own; the output is exactly the serializer's.

Parameters

format

CosyteFormat

A format for which supportsOp(format, "fmt") is true.

bytes

Uint8Array

The input bytes.

Returns

Promise<FmtResult>

The serialized text + a value-free warning count.

Throws

CLI_PARSER_UNAVAILABLE if the optional parser is absent; the wrapped parser's rejection propagates for the command's value-free failure boundary (no partial emit).

Example

import { fmtFormat } from "@cosyte/cli";

const bytes = new TextEncoder().encode('{ "resourceType":"Patient" , "id":"x" }');
(await fmtFormat("fhir", bytes)).output.startsWith("{"); // => true