Skip to content

readHdus

function readHdus(bytes, options?): ReadHdusResult;

Defined in: hdu/read-hdus.ts:264

Walk every Header-Data Unit in a FITS source. Headers are parsed; data units are located and measured but not decoded, so the whole structure of a multi-gigabyte file is enumerable from a buffer cheaply.

The deprecated random-groups format is rejected with FitsUnsupportedError. A conforming extension of an unrecognized type is returned with type: "unknown" and its bytes skipped so later HDUs stay reachable. If a structural keyword needed to size a data unit is missing or out of domain, enumeration stops there (lenient, with the HDU’s dataSizeKnown set to false) or throws FitsStructureError (strict) rather than desync every later offset.

Parameter Type
bytes Uint8Array
options ParseHeaderOptions

ReadHdusResult

import { readHdus, findHdu } from "@fits-js/core";
const { hdus } = readHdus(bytes);
const sci = findHdu(hdus, "SCI", 1);

FITS Standard v4.0 §3.3-3.4: primary HDU and extensions (random groups: §6)