Skip to content

Conversation

arthurschreiber
Copy link

No description provided.

Copy link
Member

@indutny indutny left a 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') : ''));
Copy link
Member

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.

Copy link
Author

@arthurschreiber arthurschreiber Jan 7, 2020

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.

Copy link
Author

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. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, looks great! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants