Function: filterIsoBoxes()
Call Signature
function filterIsoBoxes<T, S>(
boxes,
callback,
config?
): S[];Defined in: filterIsoBoxes.ts:21
Filters boxes in the tree that satisfy the provided testing function.
This function traverses the entire box structure (including nested boxes) and returns all boxes for which the callback returns true.
Type Parameters
T
T
S
S
Parameters
boxes
Iterable<T>
The boxes to search through
callback
(box) => box is S
A function that accepts a box and returns true if it matches
config?
Configuration options for traversal
Returns
S[]
An array of boxes that satisfy the callback, narrowed to the type S of the type guard
Example
const isoFile = await readFile(new URL('./fixtures/captions.mp4', import.meta.url))
const boxes = readIsoBoxes(isoFile, { readers: { ftyp: readFtyp } })
const filtered = filterIsoBoxes(boxes, box => isIsoBoxType('ftyp', box))
const ftyp = filtered[0]
assert.ok(ftyp)
assert.strictEqual(ftyp.type, 'ftyp')
assert.strictEqual(ftyp.majorBrand, 'isom')Call Signature
function filterIsoBoxes<T>(
boxes,
callback,
config?
): T[];Defined in: filterIsoBoxes.ts:40
Filters boxes in the tree for which a boolean callback returns true.
Use the other overload with a type guard callback to narrow the result.
Type Parameters
T
T
Parameters
boxes
Iterable<T>
The boxes to search through
callback
(box) => boolean
A function that accepts a box and returns true if it matches
config?
Configuration options for traversal
Returns
T[]
An array of boxes that satisfy the callback, with the input type T