Merge pull request #226 from KiteAnton/msp_additional_improvements

Msp additional improvements/cleanup
10.3.x-maintenance
Michael Keller 2016-08-17 08:59:06 +12:00 committed by GitHub
commit bf9b467525
2 changed files with 300 additions and 401 deletions

View File

@ -10,3 +10,48 @@ Array.prototype.push16 = function(val) {
// chainable // chainable
return this; return this;
}; };
DataView.prototype.offset = 0;
DataView.prototype.readU8 = function() {
if (this.byteLength >= this.offset+1) {
return this.getUint8(this.offset++);
} else {
return null;
}
}
DataView.prototype.readU16 = function() {
if (this.byteLength >= this.offset+2) {
return this.readU8() + this.readU8()*256;
} else {
return null;
}
}
DataView.prototype.readU32 = function() {
if (this.byteLength >= this.offset+4) {
return this.readU16() + this.readU16()*65536;
} else {
return null;
}
}
DataView.prototype.read8 = function() {
if (this.byteLength >= this.offset+1) {
return this.getInt8(this.offset++, 1);
} else {
return null;
}
}
DataView.prototype.read16 = function() {
this.offset += 2;
if (this.byteLength >= this.offset) {
return this.getInt16(this.offset-2, 1);
} else {
return null;
}
}
DataView.prototype.read32 = function() {
this.offset += 4;
if (this.byteLength >= this.offset) {
return this.getInt32(this.offset-4, 1);
} else {
return null;
}
}

File diff suppressed because it is too large Load Diff