feat: pack() type and family hints (#52) - #25690
Merged
Merged
Conversation
- pack(value, { type, family, interpret }) forces MessagePack wire types
- two-arg last-object detection; pack(1, 2) still packs an array
- Host objects, null type, and related pack-options cases - [[noreturn]] on ThrowCannotPackAs so gcovr throw edges match - GCOVR_EXCL only on unreachable hint defaults and empty info[1] - Native coverage 95.2% lines / 95.4% branches
8 tasks
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
pack(value, { type, family, interpret })so callers can forceMessagePack wire types (uint8/float32/bin/str, etc.) without changing the
default one-arg / multi-arg packing rules.
Closes #52
Options-object detection: the last argument is options only when it is a
plain object that own-enumerates at least one of
type,family,interpretand nothing else that is not those three keys. Host objects,Proxies, extra keys, and empty objects stay packed values.
pack(1, 2)isstill an array.
typewins overfamilyif both are set.masterafter BigInt feat: pack and unpack 64-bit integers as BigInt (#37) #25689 merged.Coverage (reviewer round 1)
test/pack-hints.test.js: 48 tests, including host-object optionsrejection and null/undefined type/family fall-through.
empty info[1],kTypeNone/kFamilyNonedefaults, hinted
kMaxPackDepth) markedGCOVR_EXCL_*, not deleted.ThrowCannotPackAsis[[noreturn]]so gcovr throw edges match.npm test: 185 pass / 0 fail.npm run coverage:native: 95.2% lines (902/947), 95.4% branches(836/876), 100% functions. Gate is 95%.
Test plan
npm testnpm run coverage:native