omni-compress - v2.3.10
    Preparing search index...

    Class Router

    Evaluates the execution environment and selects the optimal compression engine for each operation (fast path, AVIF encoder, heavy path / Node).

    Index

    Constructors

    Methods

    • Returns true if the format can be encoded without FFmpeg Wasm in the browser.

      • Images: OffscreenCanvas → WebP, JPEG, PNG
      • Audio: WebCodecs AudioEncoder → AAC, Opus
      • Video: WebCodecs VideoEncoder → H.264 (MP4), VP8/VP9 (WebM)

      Always returns false in Node.js (which uses native child_process instead).

      Parameters

      Returns boolean

    • Determines the full routing context for a compression job.

      Combines environment detection, fast-path eligibility, and file-size thresholds to decide whether to run on the main thread or in a Web Worker.

      Parameters

      • options: CompressorOptions

        The compression options including type and format.

      • fileSize: number

        Input file size in bytes.

      • inputMimeType: string = ''

        MIME type of the input (e.g. 'audio/wav'). Used to short-circuit audio fast-path for non-WAV inputs that would otherwise throw.

      • OptionalisWorkerWarmFn: (type: WorkerType) => boolean

        Optional callback that returns true when a Worker of the given type is already initialised. When warm, a lower threshold is used (cold-start cost is gone; only postMessage overhead remains).

      Returns RouteContext

      A RouteContext describing the chosen execution path.