# all files / node-opus/ index.js

72.73% Statements 8/11
50% Branches 1/2
0% Functions 0/1
72.73% Lines 8/11

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33

    1×
    1×

    1×
    1×
    1×

    1×

    1×
    1×

    "use strict";

    var OpusEncoder = require( './lib/OpusEncoder' );
    exports.OpusEncoder = OpusEncoder;

    var oggPacket = true;
    try {
        require( "ogg-packet" );
    } catch( ex ) {
        oggPacket = false;
    }

    // Check if the ogg packet loaded successfully.
    Eif( oggPacket ) {

        // ogg packet loaded successfully. Encoder and Decoder can be used.

        exports.Encoder = require( './lib/Encoder' );
        exports.Decoder = require( './lib/Decoder' );

    } else {

        // ogg packet not available.
        exports.Encoder = exports.Decoder = function() {
            throw new Error(
                    "ogg-packet is not available. " +
                    "Only the raw OpusEncoder can be used. " +
                    "Install ogg-packet package to use the Encoder and Decoder" );
        } ;
    }