CML
    Preparing search index...

    Function findIsoBox

    • Finds the first box in the tree that satisfies the provided testing function.

      This function traverses the entire box structure (including nested boxes) and returns the first box for which the callback returns true.

      Type Parameters

      • T
      • S

      Parameters

      • boxes: Iterable<T>

        The boxes to search through

      • callback: (box: T) => box is S

        A function that accepts a box and returns true if it matches

      • Optionalconfig: TraverseIsoBoxesConfig

        Configuration options for traversal

      Returns S | null

      The first box that satisfies the callback, or null if none is found

      const isoFile = await readFile('test/fixtures/captions.mp4')
      const boxes = readIsoBoxes(new Uint8Array(isoFile), {
      readers: {
      ftyp: readFtyp,
      }
      })

      const ftyp = findIsoBox(boxes, box => box.type === 'ftyp')

      assert.ok(ftyp)
      assert.strictEqual(ftyp.type, 'ftyp')
      assert.strictEqual(ftyp.majorBrand, 'isom')
    • Type Parameters

      • T

      Parameters

      Returns T | null