Skip to content
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

Expose utility function to enable bigint serialization in consumer apps #1706

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

axelboc
Copy link
Contributor

@axelboc axelboc commented Sep 6, 2024

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 implement BigInt.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.

image

image

image

@axelboc
Copy link
Contributor Author

axelboc commented Sep 6, 2024

/approve

packages/app/README.md Outdated Show resolved Hide resolved
packages/app/README.md Show resolved Hide resolved
@axelboc axelboc merged commit 7410a5d into main Sep 9, 2024
8 checks passed
@axelboc axelboc deleted the mock-bigint branch September 9, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants