binaryreader
v1.0.2
Published
Javascript object for reading binary data squentially
Downloads
10
Readme
BinaryReader
A javascript object for simplifying the sequential reading of binary data.
Usage
Properties
Number of bytes in the file:
reader.byteLength;
Current read position in bytes:
reader.bytePos;
Methods
Create new BinaryReader:
// dataSource: URL, ArrayBuffer, Blob, or File object to be read
// callback: function called for reading data after data has been loaded
// Use the callback to ensure that the data has been recieved before attempting to read.
// Otherwise check byteLength before attempting to read data.
var reader = new BinaryReader(dataSource, callback);
Read bytes from the file:
// numBytes: integer number of bytes to read
// radix: base of the value returned.
var bytes = reader.nextBytes(numBytes[, radix]);
Move the read position:
// numBytes: integer number of bytes to move; negative integers move backwards
reader.move(numBytes);
// NOTE: the read position is tracked internally so
// there is no need to call move() after reading data
Set the read position:
// pos: location to set the read position to
reader.setReadPos(pos);
Potential Future Features
- Support for bit level reads