/**
 * Subclass of jDataView with a getUint64 method.
 */
define([
           'jDataView'
       ],
       function( jDataView ) {

var DataView = function() {
    jDataView.apply( this, arguments );
};
DataView.prototype = new jDataView( new ArrayBuffer() );

/**
 * Get a 53-bit integer from 64 bits and approximate the number if it overflows.
 */
DataView.prototype.getUint64Approx = function( byteOffset, littleEndian ) {
    var b = this._getBytes(8, byteOffset, littleEndian);
    var result = b[0] * Math.pow(2,56) + b[1]*Math.pow(2,48) + b[2]*Math.pow(2,40) + b[3]*Math.pow(2,32) +  b[4]*Math.pow(2, 24) + (b[5]<<16) + (b[6]<<8) + b[7];

    if( b[0] || b[1]&224 ) {
        result = new Number(result);
        result.overflow = true;
    }

    return result;
};

/**
 * Get a 53-bit integer from 64 bits and die if it overflows.
 */
DataView.prototype.getUint64 = function( byteOffset, littleEndian ) {
    var result = this.getUint64Approx( byteOffset, littleEndian );
    if( result.overflow )
        throw 'integer overflow';
    return result;
};


return DataView;

});
/**
 * Subclass of jDataView with a getUint64 method.
 */
define([
           'jDataView'
       ],
       function( jDataView ) {

var DataView = function() {
    jDataView.apply( this, arguments );
};

try {
    DataView.prototype = new jDataView( new ArrayBuffer() );
} catch(e) {}

/**
 * Get a 53-bit integer from 64 bits and approximate the number if it overflows.
 */
DataView.prototype.getUint64Approx = function( byteOffset, littleEndian ) {
    var b = this._getBytes(8, byteOffset, littleEndian);
    var result = b[0] * Math.pow(2,56) + b[1]*Math.pow(2,48) + b[2]*Math.pow(2,40) + b[3]*Math.pow(2,32) +  b[4]*Math.pow(2, 24) + (b[5]<<16) + (b[6]<<8) + b[7];

    if( b[0] || b[1]&224 ) {
        result = new Number(result);
        result.overflow = true;
    }

    return result;
};

/**
 * Get a 53-bit integer from 64 bits and die if it overflows.
 */
DataView.prototype.getUint64 = function( byteOffset, littleEndian ) {
    var result = this.getUint64Approx( byteOffset, littleEndian );
    if( result.overflow )
        throw 'integer overflow';
    return result;
};


return DataView;

});
make JBrowse/Model/DataView not crash on load in browsers that don't have typed arrays