Slide 8
Slide 8 text
Typed Array Support!
• Oh, thank god, Typed Arrays!!
• DataView!
!
!this.getUint8 = function(offset) {!
! !if (compatibility.ArrayBuffer) {!
! ! !return new Uint8Array(this.buffer, offset, 1)[0];!
! !}!
! !else {!
! ! !return this.data.charCodeAt(offset) & 0xff;!
! !}!
!}!
//Returns a ULONG integer!
!
!var b3 = this.getUint8(this.endianness(offset, 0, 4, littleEndian)),!
! b2 = this.getUint8(this.endianness(offset, 1, 4, littleEndian)),!
! b1 = this.getUint8(this.endianness(offset, 2, 4, littleEndian)),!
! b0 = this.getUint8(this.endianness(offset, 3, 4, littleEndian));!
!
!return (b3 * Math.pow(2, 24)) + (b2 << 16) + (b1 << 8) + b0;!
!