The traverseIsoBoxes function traverses box iterators and returns a generator of boxes. It takes an iterable of boxes and two optional arguments: depth-first traversal and maximum depth. By default, the function traverses depth-first with a maximum depth of infinity. A maximum depth of 0 traverses only the root boxes.
import { traverseIsoBoxes } from "@svta/cml-iso-bmff";
const boxes = traverseIsoBoxes(buffer);
The library provides type guards that check whether a box is a container box or a full box. These guards narrow the type of a box in TypeScript.
isContainer checks whether a box is a container box.
import { isContainer } from "@svta/cml-iso-bmff";
const box = { type: "meta", boxes: [] };
const isContainer = isContainer(box);
isFullBox checks whether a box is a full box.
import { isFullBox } from "@svta/cml-iso-bmff";
const box = { type: "meta", version: 1, flags: 0 };
const isFullBox = isFullBox(box);