-
Notifications
You must be signed in to change notification settings - Fork 633
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
feat: msgpack encoding #3460
feat: msgpack encoding #3460
Conversation
I should note that I plan for at least one follow-up PR. We don't support the timestamp extension to the spec yet, but I think that's fine for making the first PR reviewable. |
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.
Nice work in general! Needs a bit of work.
lgtm |
@aapoalas What do you think? |
I'll try to review this fully in some hours. |
How am I failing CI if main isn't? Super strange. |
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.
Found some nits to pick and a few remaining issues from the encode side.
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.
Nice work! I think in a followup we could try to optimise the encoding side via eg. eagerly allocating a larger buffer that we use as needed and reallocate a bigger one if needed. Or we could precalculate the size we need (strings would need to be "eyeballed" or allocated to the theoretical maximum of length * 3).
Also, an "encodeInto" API is probably a good idea in the future.
Lots of good ideas for follow up PRs. Copying this from discord so that we have all of the ideas in the same thread:
|
Let me finish up some final cleanups around comments and bitshift stuff and I think this PR is good. |
@kt3k please take a look! |
@kt3k What do you think? |
return value; | ||
} | ||
case 0xcf: { // uint 64 | ||
const value = dataView.getBigUint64(pointer.consumed); |
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.
Does this mean integer
type in msgpack could become both number
and bigint
in JS? Is this the same as the other decoders such as msgpackr
?
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.
Does this mean integer type in msgpack could become both number and bigint in JS?
There are multiple integer types, but yes. Some integer types (u64 + i64) will be converted to a bigint instead of a number.
Is this the same as the other decoders such as msgpackr?
It appears that msgpack does the same thing (always storing it in a u64/i64 and erroring out if the number is too big)
Co-authored-by: Yoshiya Hinosawa <[email protected]>
Let's add jsdocs to |
Other part looks good to me |
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. Looks nice addition to std. Thanks for your contribution! @lino-levan
Closes #2194.