fix: messages transformed with message-unpack-stream are incorrect in some cases #48
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.
fix: message-unpack-stream parses messages incorrectly in some cases
The
message-unpack-stream
parses messages incorrectly in case a message with length less than Header length (4) is received - this leads to indefinite recursion. The problem has been introduced in #24 which was fixing another issue - when the length of the new message is less than the buffer header and there's something in the_unfinishedMessage
.To resolve the issue, get the previous logic and improve the check - in case we have partial message from the previous time, just add the current message to it and get in the recursion. In case we do not have previous message and current data is less than 4 bytes, just put it in the
_unfinishedMessage
and wait for new data.feat: add tests for message-unpack-stream
Add tests for message-unpack-stream.
Add mocha, chai and istanbul as devDependencies and ensure tests are run before packing the package. Ignore test specific files from the npm package and coverage files from git.
feat: export MessageUnpackStream class
Export MessageUnpackStream class from the index.js, so once the package is required, you can create instances of both IOSDeviceLib and MessageUnpackStream. Move the implementation of IOSDeviceLib to a separate file to simplify the entry point.