Function: detectFormat()
detectFormat(
bytes):DetectResult
Detect the healthcare format of bytes by content, conservatively.
Parameters
bytes
Uint8Array
The input bytes (a whole file or a stdin buffer). Only the leading prefix is sniffed.
Returns
A DetectResult: certain + a format on a single match, else ambiguous/none
with format: null and the value-free candidates list. Never guesses.
Example
import { detectFormat } from "@cosyte/cli";
const enc = new TextEncoder();
detectFormat(enc.encode("MSH|^~\\&|A|B\r")).format; // => "hl7"
detectFormat(enc.encode('{"resourceType":"Patient"}')).format; // => "fhir"
detectFormat(enc.encode("hello")).confidence; // => "none"