Skip to content
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

Parse #24

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Parse #24

wants to merge 8 commits into from

Conversation

articice
Copy link

@articice articice commented Nov 30, 2016

Hi!

I've added two methods - parse and rest.

parse is 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).

rest is 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 static buffer, 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, rest allows cutting out non-terminated or EOM terminated strings of "unknown" lengths (in the last data segment for a parsing loop inside 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.

@articice
Copy link
Author

Oops, I've entirely missed that this module has mocha tests part and CI checks based on it.
Will work on tests, pushing onto this branch.

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.

1 participant