Add typed numeric wrappers and precise number mode to gremlin-javascript#3427
Open
kirill-stepanishin wants to merge 1 commit into
Open
Add typed numeric wrappers and precise number mode to gremlin-javascript#3427kirill-stepanishin wants to merge 1 commit into
kirill-stepanishin wants to merge 1 commit into
Conversation
Assisted-by: Claude Code:claude-opus-4-6
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3427 +/- ##
============================================
- Coverage 77.87% 76.32% -1.55%
+ Complexity 13578 13439 -139
============================================
Files 1015 1013 -2
Lines 59308 60417 +1109
Branches 6835 7091 +256
============================================
- Hits 46184 46113 -71
- Misses 10817 11583 +766
- Partials 2307 2721 +414 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
GumpacG
reviewed
May 15, 2026
| |options.traversalSource |String |The traversal source. |'g' | ||
| |options.headers |Object |Additional HTTP header key/values included with each request. |undefined | ||
| |options.interceptors |RequestInterceptor/RequestInterceptor[] |One or more functions that can modify the HTTP request before it is sent. |undefined | ||
| |options.numberMode |String |Set to `'precise'` to wrap deserialized numbers in typed wrappers that preserve the server's original type. |undefined |
Contributor
There was a problem hiding this comment.
How many modes are there? If it's only precise or not can we rename the option and make it a boolean?
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
JavaScript's single
Numbertype (IEEE 754 double) loses the distinction between JVM numeric types likeint,float,long, anddouble. This PR givesgremlin-javascriptusers explicit control over numeric type fidelity on both sides of the wire.Serialization — New wrapper classes and factory functions (
toInt,toFloat,toDouble,toLong,toShort,toByte) control the exact GraphBinary type code and GremlinLang suffix sent to the server. Without wrappers, existing type-inference behavior is unchanged.Deserialization — A new
numberMode: 'precise'connection option wraps incoming numeric values in the same typed wrappers, preserving the server's original type information. Wrappers support transparent arithmetic viavalueOf/Symbol.toPrimitive, and anunwrap()helper extracts raw values.Implementation — Refactored
GraphBinary.jsIoC initialization into acreateIoc()factory so precise mode can inject apostDeserializehook viaAnySerializer. ExtendedNumberSerializationStrategyandGremlinLangto route wrapper instances to the correct serializers/suffixes. EnhancedLongto acceptbigintwith full int64 range validation.Tests
Int/Doublewrappers on vertex properties and edge weightsDocumentation