Function: isIsoBoxType()
Call Signature
function isIsoBoxType<T, V>(type, box): box is IsoBoxMap<V>[T];Defined in: isIsoBoxType.ts:23
Check if a box is of a specific type. This is a type guard function.
The function returns false for a raw box. A raw box has the type of its box and a bytes field, and it has no other field of the box. A box that readIsoBoxes returns narrows to the box type with the 64-bit integer fields of that box. The function checks the type field and that the box has no bytes field. It does not check the other fields. A value of another type narrows to the box type with number fields.
Type Parameters
T
T extends keyof IsoBuiltInBoxMap<number>
V
V extends IsoInt64 = number
Parameters
type
T
The type to check for
box
| IsoBox<V> | { type: string; } | null | undefined
The box to check
Returns
box is IsoBoxMap<V>[T]
true if the box is of the specified type and is not a raw box, false otherwise
Example
const isoFile = await readFile(new URL('./fixtures/mss_moof_tfdt.mp4', import.meta.url))
const boxes = readIsoBoxes(isoFile, { readers: { tfdt: readTfdt } })
const times: number[] = []
for (const box of traverseIsoBoxes(boxes)) {
if (isIsoBoxType('tfdt', box)) {
times.push(box.baseMediaDecodeTime)
}
}Call Signature
function isIsoBoxType<T>(type, box): box is IsoBoxMap[T];Defined in: isIsoBoxType.ts:40
Check if a value of an unknown type is a box of a specific type. This is a type guard function.
The value narrows to the box type with number fields.
Type Parameters
T
T extends keyof IsoBuiltInBoxMap<number>
Parameters
type
T
The type to check for
box
unknown
The value to check
Returns
box is IsoBoxMap[T]
true if the value is a box of the specified type and is not a raw box, false otherwise