-
Notifications
You must be signed in to change notification settings - Fork 382
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
[]byte/string parameter conversion oddity #51
Comments
I'm not sure []byte should be converted to string. Not only they are distinct data types, but one is immutable, the other is not. This means the data will be copied during the conversion which is inconsistent with how it normally works. I had an idea of converting []byte into ArrayBuffer which is more suitable, but never really had the time to implement it. |
Hm, good point. The dilemma we're facing with k6 is that we need some functions to accept string literals, but we also need to be able to handle binary data (POST-ing images being the big one that comes up) in some kind of sane fashion. If I were to contribute an ArrayBuffer implementation, how would I go about doing it? |
Make sure it passes all relevant tc39 tests and raise a PR. However you could consider wrapping []byte into a custom type before passing it to ToValue(). You could then define methods on that type and use them in JS. It all depends on what you want to do with it... |
I'm closing this, if you do implement ArrayBuffer, please raise a PR |
Expected "hi", got "104,105". Looks like mangling of arrays that could use a special case for
[]byte
? The opposite direction appears to work just fine.The text was updated successfully, but these errors were encountered: