-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new Int
node to parse intBE
, intLE
, uIntBE
and uIntLE
values.
#1
base: master
Are you sure you want to change the base?
Add a new Int
node to parse intBE
, intLE
, uIntBE
and uIntLE
values.
#1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a tests, but otherwise looks pretty good!
src/node/int.ts
Outdated
* @param field State's property name | ||
*/ | ||
constructor(public readonly field: string, public readonly bytes: number, public readonly signed: boolean, public readonly littleEndian: boolean) { | ||
super(field + '_' + (signed ? 'int' : 'uint') + '_' + (bytes * 8) + (bytes > 1 ? '_' + (littleEndian ? 'le' : 'be') : '')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: let's move compound expressions to separate variables and use template syntax here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit problematic - the super
call needs to be the very first instruction in the constuctor. 😞I'll try to clean this up a but with the template syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted the name generation to a separate function to work around the super
call requirement. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, looks great! 👍
No description provided.