-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
source/parser/comptime.civet
Outdated
`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:: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. globalThis
?
There was a problem hiding this comment.
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
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.