The binaryXHR Javascript module implements a set of functions and classes that can be used to retrieve binary files using the XMLHttpRequest API. |
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.
Load a binary file.
Arguments:
url:string - URL from where to load the binary file.
Output:
An object of type BinaryFile.
Initiate an asynchronous binary load.
Arguments:
url:string - URL from where to load the binary file.
callback:function(obj[,arg]) - Pointer to the function that will
be called when the binary file has been loaded.
The function will be
given one or two arguments; the first one is an object of type BinaryFile.
The second one is the argument described below, if available.
callback_arg:any (optional) - If present, it will be given as argument to the callback function.
Output:
A reference to the XMLHttpRequest object.
It may be used to verify the status of the load or to implement timeouts.
The callback function will receive the loaded binary file.
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. |
getSByteAt(idx) |
Return an 8 bit signed integer from offset idx. |
getSShortAt(idx) |
Return a 16 bit little endian signed integer from offset idx. |
getSLongAt(idx) |
Return a 32 bit little endian signed integer from offset idx. |
getDoubleAt(idx) |
Return a double float (64 bit little endian) from offset idx. Return undefined if the value is not a float or is infinity. |
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. Return undefined if the value is not a float or is infinity. |
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. |
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://javascriptrrd.sourceforge.net.
|