mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-25 22:55:49 +00:00
refactored ./src/types/path-set (#84)
Refactored PathSet, Path, and Hop types. Constructing these types with Buffers, and using class instead of makeClass.
This commit is contained in:
@@ -16,6 +16,16 @@ class BinaryParser {
|
||||
this.bytes = Buffer.from(hexBytes, "hex");
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek the first byte of the BinaryParser
|
||||
*
|
||||
* @returns The first byte of the BinaryParser
|
||||
*/
|
||||
peek(): number {
|
||||
assert(this.bytes.byteLength !== 0);
|
||||
return this.bytes[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume the first n bytes of the BinaryParser
|
||||
*
|
||||
@@ -33,7 +43,10 @@ class BinaryParser {
|
||||
* @return The bytes
|
||||
*/
|
||||
read(n: number): Buffer {
|
||||
assert(n <= this.bytes.byteLength, n + " greater than " + this.bytes.byteLength);
|
||||
assert(
|
||||
n <= this.bytes.byteLength,
|
||||
n + " greater than " + this.bytes.byteLength
|
||||
);
|
||||
|
||||
const slice = this.bytes.slice(0, n);
|
||||
this.skip(n);
|
||||
|
||||
Reference in New Issue
Block a user