You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
558 B

// Reads data in little-endian format
export default class DataScanner {
offset: number;
view: DataView;
constructor(data: DataView | ArrayBuffer) {
this.offset = 0;
this.view = data instanceof DataView ? data : new DataView(data);
}
float32(): number {
const x = this.view.getFloat32(this.offset, true);
this.offset += 4;
return x;
}
uint8(): number {
return this.view.getUint8(this.offset++);
}
uint32(): number {
const x = this.view.getUint32(this.offset, true);
this.offset += 4;
return x;
}
}