-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Added packet timeout for cctalk parser #1887
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.
Code looks good, but please add a test. You can use sinon to mock time.
packages/parser-cctalk/cctalk.js
Outdated
} | ||
_transform(buffer, _, cb) { | ||
if (this.maxDelayBetweenBytesMs > 0) { | ||
const now = +new Date() |
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.
Date.now()
is a little more straightforward
packages/parser-cctalk/cctalk.js
Outdated
@@ -12,12 +12,23 @@ const parser = port.pipe(new CCtalk()) | |||
parser.on('data', console.log) | |||
*/ | |||
class CCTalkParser extends Transform { | |||
constructor() { | |||
constructor(maxDelayBetweenBytesMs = 0) { |
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.
packetTimeout
? Also per the spec, should 50 be the default?
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.
Yes, 50ms is the default. But it may break someone's code. I have set 0 for backward compatibility. Is it better to set it to 50 by default?
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.
We can do a major version release so it won’t break anyone’s code without them purposely upgrading.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week no further activity occurs. Feel free continue the discussion or ask for a |
…r. Code readability fix
Hi, @reconbot ! |
Please, tell me if I should do something more |
nothing at all, I'm just slow |
Should fix #1886