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

Serialize typed arrays and well-known symbols #1188

Merged
merged 2 commits into from
Apr 27, 2024

Conversation

bbrk24
Copy link
Contributor

@bbrk24 bbrk24 commented Apr 27, 2024

Typed arrays were briefly discussed on the discord last night. While I didn't mention well-known symbols, they seem useful and were also pretty straightforward to implement.

I believe symbol-keyed properties in objects are still not serialized, but that can be a separate issue.

@bbrk24 bbrk24 changed the title Add typed arrays and well-known symbols Serialize typed arrays and well-known symbols Apr 27, 2024
`new ${val.constructor.name}([${(val as any).join ','}])`
when BigInt64Array::, BigUint64Array::
`new ${val.constructor.name}([${Array.from(val as ArrayLike<bigint>, `${&}n`).join ','}])`
when Buffer::
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test this on the browser build? (yarn docs:dev, click on Playground) I'm worried about what happens when this global isn't defined. Maybe global.Buffer works better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work fine, but I'm surprised that it does. I'll change this to global.Buffer?:: or whatever the correct syntax is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So not only does that spelling not work (#1191), global doesn't exist in the browser, either!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. globalThis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, globalThis seemed to work. Thank you JavaScript very cool

@edemaine edemaine merged commit f929c6d into DanielXMoore:main Apr 27, 2024
3 checks passed
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