mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-25 22:55:49 +00:00
passed tests (however, the test cases themselves are unverified.)
This commit is contained in:
@@ -57,6 +57,7 @@ SerializedObject.prototype.resetPointer = function () {
|
||||
this.pointer = 0;
|
||||
};
|
||||
|
||||
/*
|
||||
SerializedObject.prototype.read = function (numberOfBytes) {
|
||||
var start = this.pointer;
|
||||
var end = start+numberOfBytes;
|
||||
@@ -68,6 +69,23 @@ SerializedObject.prototype.read = function (numberOfBytes) {
|
||||
return result;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
var readOrPeek = function (advance) {
|
||||
return function(numberOfBytes) {
|
||||
var start = this.pointer;
|
||||
var end = start+numberOfBytes;
|
||||
if (end > this.buffer.length) {
|
||||
throw new Error("There aren't that many bytes left.");
|
||||
} else {
|
||||
var result = this.buffer.slice(start,end);
|
||||
if (advance) {this.pointer = end;}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
SerializedObject.prototype.read = readOrPeek(true);
|
||||
SerializedObject.prototype.peek = readOrPeek(false);
|
||||
|
||||
|
||||
SerializedObject.prototype.to_bits = function ()
|
||||
|
||||
Reference in New Issue
Block a user