mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-26 15:15:49 +00:00
Refactor ./src/enums (#73)
* rewrote enums in TS * changed folder name to src/definitions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { strict as assert } from "assert";
|
||||
import { makeClass } from "../utils/make-class";
|
||||
import { Enums } from "../enums";
|
||||
import { Field } from "../definitions";
|
||||
import { slice, parseBytes } from "../utils/bytes-utils";
|
||||
|
||||
const BinaryParser = makeClass(
|
||||
@@ -68,7 +68,7 @@ const BinaryParser = makeClass(
|
||||
return (type << 16) | nth;
|
||||
},
|
||||
readField() {
|
||||
return Enums.Field.from(this.readFieldOrdinal());
|
||||
return Field.fromString(this.readFieldOrdinal().toString());
|
||||
},
|
||||
readType(type) {
|
||||
return type.fromParser(this);
|
||||
@@ -81,7 +81,9 @@ const BinaryParser = makeClass(
|
||||
if (!kls) {
|
||||
throw new Error(`unsupported: (${field.name}, ${field.type.name})`);
|
||||
}
|
||||
const sizeHint = field.isVLEncoded ? this.readVLLength() : null;
|
||||
const sizeHint = field.isVariableLengthEncoded
|
||||
? this.readVLLength()
|
||||
: null;
|
||||
const value = kls.fromParser(this, sizeHint);
|
||||
if (value === undefined) {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user