-
-
Notifications
You must be signed in to change notification settings - Fork 1
Complete BSON codec implementation with decoder and encoder improvements #18
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
Conversation
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
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.
Add automated.spec.ts
and fuzzer.spec.ts
tests, similar to how it is done in src/resp/
.
@@ -305,13 +326,13 @@ export class BsonEncoder implements BinaryJsonEncoder { | |||
case BsonInt64: { | |||
writer.u8(0x12); | |||
this.writeCString(key); | |||
this.writeInt64((value as BsonInt32).value); | |||
this.writeInt64((value as BsonInt64).value); |
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.
Good catch.
Run |
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Added both |
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Fixed all TSLint errors and applied prettier formatting. The specific issues addressed:
All 232 BSON tests are still passing. (5c3ba1c) |
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.
LGTM
🎉 This PR is included in version 1.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR completes the BSON codec implementation by adding a fully functional
BsonDecoder
and fixing several issues in the existingBsonEncoder
.What was implemented
BsonDecoder
A complete BSON decoder supporting all BSON specification v1.1 types:
The decoder properly handles:
BsonEncoder Improvements
Fixed several issues in the existing encoder:
BsonInt64
andBsonFloat
casesBsonJavascriptCodeWithScope
encodingBinaryJsonEncoder
methods with appropriate error messageswriteAsciiStr
to delegate towriteStr
for proper UTF-8 handlingComprehensive Testing
Added 34 comprehensive tests covering:
bson
library for validationExample Usage
Technical Details
The implementation follows the BSON specification v1.1 exactly:
int32 e_list unsigned_byte(0)
int32 (byte*) unsigned_byte(0)
with UTF-8 encodingAll 161 tests pass, including existing encoder tests and new decoder tests, ensuring robust compatibility and correctness.
Fixes #17.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.