binaryXHR module


The binaryXHR Javascript module implements a set of functions and classes that can be used to retrieve binary files using the XMLHttpRequest API.


Overview

This module provides two functions, FetchBinaryURL and FetchBinaryURLAsync, that are wrappers around the XMLHttpRequest API and return an object of type BinaryFile. The first one implements a straight load, while the second one initiates an asynchronous operation handled by a callback function.

The BinaryFile class implements the methods needed to access the elements of the binary files, such as strings, integers and real numbers.

Both the functions and the class internally handle the differences between different Web Browsers, so the user of this module does not need to worry about them.

Function FetchBinaryURL

Load a binary file.

Arguments:

Output:

Function FetchBinaryURLAsync

Initiate an asynchronous binary load.

Arguments:

Output:

Class BinaryFile

This class implements the methods needed to access the content of the binary file.

Method

Description

getLength()

Return the number of bytes held by the object.

getByteAt(idx)

Return an 8 bit unsigned integer from offset idx.

getShortAt(idx)

Return a 16 bit little endian unsigned integer from offset idx.

getLongAt(idx)

Return a 32 bit little endian unsigned integer from offset idx.

getDoubleAt(idx)

Return a double float (64 bit little endian) from offset idx.

getFastDoubleAt(idx)

Return a low resolution (20 bit mantissa) double flat obtained from the high 32 bits of the original little endian double float from offset idx.

getCharAt(idx)

Get a character from offset idx.

getCStringAt(idx,maxlen)

Get a zero terminated string of limited size from offset idx.

getStringAt(idx,len)

Get a fixed length string from offset idx.

Exception class InvalidBinaryFile

This is a helper exception class that can be thrown while loading the binary file.



This module is part of the javascriptRRD package hosted at http://javascript.sourceforge.net.
It is licensed under the MIT licanse.