You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IO.PrimitiveReader = function (data) {
var arr = Array.from(new Uint8Array(data));
var fn = {};
var position = 0;
fn.read = function (length) {
var result = arr.slice(position, position + length);
position += length;
return result;
};
/* read a big-endian 32-bit integer */
fn.readInt32 = function () {
var result = (
(arr[position] << 24)
+ (arr[position + 1] << 16)
+ (arr[position + 2] << 8)
+ arr[position + 3]);
position += 4;
return result;
}
/* read a big-endian 16-bit integer */
fn.readInt16 = function () {
var result = (
(arr[position] << 8)
+ arr[position + 1]);
position += 2;
return result;
}
/* read an 8-bit integer */
fn.readInt8 = function (signed) {
var result = arr[position];
if (signed && result > 127)
result -= 256;
position += 1;
return result;
}
fn.eof = function () {
return position >= arr.length;
}
fn.readVarInt = function () {
var result = 0;
while (true) {
var b = fn.readInt8();
if (b & 0x80) {
result += (b & 0x7f);
result <<= 7;
} else {
/* b is the last byte */
return result + b;
}
}
};
return fn;
};
The text was updated successfully, but these errors were encountered:
IO.PrimitiveReader = function (data) {
var arr = Array.from(new Uint8Array(data));
var fn = {};
var position = 0;
The text was updated successfully, but these errors were encountered: