Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(() => {
toRestore.writeByte = ByteBuffer.prototype.writeByte;
toRestore.writeInt = ByteBuffer.prototype.writeInt;
toRestore.writeLong = (ByteBuffer.prototype as any).writeLong;
toRestore.toBuffer = ByteBuffer.prototype.toBuffer;
toRestore.flip = ByteBuffer.prototype.flip;
});
beforeEach(() => {
before(() => {
toRestore.writeByte = ByteBuffer.prototype.writeByte;
toRestore.writeInt = ByteBuffer.prototype.writeInt;
toRestore.writeLong = (ByteBuffer.prototype as any).writeLong;
toRestore.flip = ByteBuffer.prototype.flip;
});
beforeEach(() => {
before(() => {
toRestore.writeByte = ByteBuffer.prototype.writeByte;
toRestore.writeInt = ByteBuffer.prototype.writeInt;
toRestore.writeLong = (ByteBuffer.prototype as any).writeLong;
toRestore.toBuffer = ByteBuffer.prototype.toBuffer;
toRestore.flip = ByteBuffer.prototype.flip;
});
beforeEach(() => {
before(() => {
toRestore.writeByte = ByteBuffer.prototype.writeByte;
toRestore.writeInt = ByteBuffer.prototype.writeInt;
toRestore.writeLong = (ByteBuffer.prototype as any).writeLong;
toRestore.flip = ByteBuffer.prototype.flip;
});
beforeEach(() => {
}
return this.readBytes(length, offset);
};
ByteBuffer.prototype.readIBytes = function (offset) {
var length = this.readInt32(offset);
if (typeof offset !== 'undefined') {
offset += 4;
}
return this.readBytes(length, offset);
};
ByteBuffer.prototype.toSlicedBuffer = function () {
return this.buffer.slice(this.offset, this.limit);
};
module.exports = ByteBuffer;
var ByteBuffer = require('bytebuffer');
ByteBuffer.prototype.readVBytes = function (offset) {
var length = this.readVarint32(offset);
if (typeof offset !== 'undefined') {
offset += length.length;
length = length.value;
}
return this.readBytes(length, offset);
};
ByteBuffer.prototype.readIBytes = function (offset) {
var length = this.readInt32(offset);
if (typeof offset !== 'undefined') {
offset += 4;
}
const ByteBuffer = require("bytebuffer");
const $ = require("./conversions");
ByteBuffer.prototype.writeVarint = function (int, offset = undefined) {
if (0 < int && int < 0xfd) {
return {value: int, length: 1};
} else if (0xfd < int && int <= 0xffff) {
return {
value: parseInt("0xFD" + $.bytesToHex($.numToBytes(int, 2)), 16),
length: 2
};
} else if (0xffff < int && int <= 0xffffffff) {
return {
value: parseInt("0xFE" + $.bytesToHex($.numToBytes(int, 4)), 16),
length: 4
};
} else if (0xffffffff < int && int <= 0xffffffffffffffff) {
return {
value: parseInt("0xFF" + $.bytesToHex($.numToBytes(int, 8)), 16),
length: 8
var ByteBuffer = require('bytebuffer');
ByteBuffer.prototype.readVBytes = function (offset) {
var length = this.readVarint32(offset);
if (typeof offset !== 'undefined') {
offset += length.length;
length = length.value;
}
return this.readBytes(length, offset);
};
ByteBuffer.prototype.readIBytes = function (offset) {
var length = this.readInt32(offset);
if (typeof offset !== 'undefined') {
offset += 4;
}
return this.readBytes(length, offset);
};
ByteBuffer.prototype.toSlicedBuffer = function () {
return this.buffer.slice(this.offset, this.limit);
};
module.exports = ByteBuffer;
} else if (0xffff < int && int <= 0xffffffff) {
return {
value: parseInt("0xFE" + $.bytesToHex($.numToBytes(int, 4)), 16),
length: 4
};
} else if (0xffffffff < int && int <= 0xffffffffffffffff) {
return {
value: parseInt("0xFF" + $.bytesToHex($.numToBytes(int, 8)), 16),
length: 8
};
} else {
throw ("Wrong value for varint: ", int.toString("hex"));
}
};
ByteBuffer.prototype.parseVarint = function (offset = undefined) {
const header = parseInt(this.toHex(offset, offset + 1), 16);
if (0 <= header && header < 0xfd) {
return {
value: header,
length: 1
};
} else if (header === 0xfd) {
return {
value: parseInt(this.toHex(offset + 1, offset + 3)),
length: 2
};
} else if (header === 0xfe) {
return {