msgpack-javascript
msgpack-javascript copied to clipboard
encoder: Encode instances of Number as numbers, not maps
Make sure instances of Number as encoded as a number instead of a map.
I am encountering this issue in my current project, I believe this is a more sensible default behavior
All tests pass.
:warning: Please install the to ensure uploads and comments are reliably processed by Codecov.
Codecov Report
Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
Project coverage is 97.19%. Comparing base (
59057ee) to head (b450e25). Report is 3 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/Encoder.ts | 50.00% | 1 Missing :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## main #271 +/- ##
==========================================
- Coverage 97.28% 97.19% -0.09%
==========================================
Files 17 17
Lines 1140 1142 +2
Branches 253 254 +1
==========================================
+ Hits 1109 1110 +1
- Misses 31 32 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Why do you use the Number wrapper object? There's no reason to use it and it seems just a bug, in your project.
I am not going to go too much into the details of my project because this is not the place, but it turns out that I have a need for representing a integer using an object instance rather than a primitive type, a need which Number was built into the language to fulfill. This is a deliberate choice, not a bug.
My goal with this PR is merely to point out that Number does exist today as a core part of the language (has since ES1, really), and so the question this poses here is:
- Do we consider the MessagePack representation of it should be a map
- Or do we consider it should be a int/float?
@gfx Any thoughts on the above?