Dump Serializable.fromBinary()

This commit is contained in:
László Monda
2016-04-03 02:38:23 +02:00
parent 2b91aa3152
commit ec65753246
2 changed files with 27 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ class UhkBuffer {
private static stringEncoding = 'utf8';
offset: number;
enableDump = false;
private buffer: Buffer;
private bytesToBacktrack: number;
@@ -32,12 +33,14 @@ class UhkBuffer {
let value = this.buffer.readUInt8(this.offset);
this.bytesToBacktrack = 1;
this.offset += this.bytesToBacktrack;
this.dump(`uint8(${value}) `);
return value;
}
writeUInt8(value: number): void {
this.buffer.writeUInt8(value, this.offset);
this.offset += 1;
this.dump(`uint8(${value}) `);
}
readInt16(): number {
@@ -134,4 +137,10 @@ class UhkBuffer {
getBufferContent(): Buffer {
return this.buffer.slice(0, this.offset);
}
dump(value) {
if (this.enableDump) {
process.stdout.write(value);
}
}
}