Expose utility function to enable bigint serialization in consumer apps #1706
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.
In preparation to adding support for bigints (cf. #1679), I add a few mock datasets with
bigint
literals and I implement an opt-in way to enable big int serialization for the Raw visualization and metadata viewer in consumer apps.For
JSON.stringify()
to support bigint, one has to implementBigInt.prototype.toJSON
. I really don't want to do this in@h5web/app
or@h5web/lib
because extending built-in objects is dangerous. If H5Web is integrated into an app that already implements its own JSON serialization, H5Web could unknowingly break this parent app. That's why I think it's safer to give this responsibility to the consumer app.Since the goal is for providers to return bigint values/typed arrays if possible, and since there will always be cases where bigints need to be serialized for display (attributes, nested compounds, etc.), this should at least provide a much more robust and future-proof solution for #1536.