Open
Conversation
(using Buffer object and stacking of Buffers)
Author
|
Oops, I've entirely missed that this module has mocha tests part and CI checks based on it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi!
I've added two methods -
parseandrest.parseis taken by analogy from node-binary but still keeps this module's code small, neat and clean. It is essential for TCP framing in a stream parser. It can be useful for defining strict boundaries for data segments inside a frame or a stream (although I didn't do it in my application).restis an important improvement, that does not exist in node-binary or dissolve-chunks. It allows the user to cut the rest of the frame without explicitly tracking current parsing position (and needed length). Of course, frame length is defined by the length of a previously sliced staticbuffer, but if the internal parsing routine is complicated enough (see simplified real-life example), keeping track of buffer length left is tedious; while dissolve does not export a "parser position" property, and personally, I think it should stay this way. In my example,restallows cutting out non-terminated or EOM terminated strings of "unknown" lengths (in the last data segment for a parsingloopinside a data frame).dissolve-chunks, while having an interesting approach to parsing data segments (they call it "chunks"), unfortunately, only relies on fixed length known beforehand.