-
Notifications
You must be signed in to change notification settings - Fork 91
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
Include Buffer Support in the Standard Library #148
Conversation
* fs.readFile now returns a buffer, instead of a string * fs.writeFile now accepts a string or a buffer for the contents argument
This commit implements buffer types are arguments and returns for previously used string types for the @lune/net library. Methods affected: * net.request - Returns resp body as a buffer now * net.serve - RequestConfig handlers can have a body of type string or buffer now * net.socket - WebSocket stream data can now be sent as a string or buffer
@filiptibell Could we decide on a design for this? Looking forward to getting this implemented soon, buffers aren't very useful inside lune atm. |
I think we can start with just accepting a Right now we don't have a performant way of converting to/from buffer userdata values though - making this more or less useless since performance is the main benefit of buffers - I have opened an issue for this at mlua-rs/mlua#378 |
That clarifies a bunch now, guess I can change the PR up to do the above. Although I do think we should default to returning buffers for APIs sometime in the future (I've noticed that most runtimes like NodeJS do this for fs reads and similar). |
Latest |
Awesome! I'll get started on this sometime soon, in that case :) |
Since this is now a part of the 0.9.0 milestone, I'll implement the breaking changes as well. |
We still don't know which APIs should change and how, or if it should be separate options to return buffers. |
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.
Found a typedef that shouldn't have changed but otherwise LGTM 👍
Co-authored-by: Filip Tibell <[email protected]>
Seems like serde tests for compression are failing after merging this.. I'm a bit confused as to why, the tests passed in the PR itself, and the test files have not changed according to git either |
That's... odd. I'll investigate and lyk. |
After compressing Using |
I've fixed up all of the test files and discrepancies. I'm leaving a mini-postmortem here for future reference and anyone interested:
After figuring out parameters for each compression cli and re-generating the test files using this much more deterministic method, tests started to pass....except for lz4. It turns out It may be worth considering if we should test for exact matches in output like this at all, since the output may vary depending on the zlib implementation used, but I think I at least left the tests in a much better state. If this happens again we can just run the test file generation again and verify that things are still ok. |
This PR aims to to implement support for buffers, the new luau datatype in argument and return types of functions in the lune standard library where appropriate.
TODO:
returns andparams@lune/fs
writeFile
@lune/net
FetchParams.body
ServeResponse.body
WebSocket.send
@lune/serde
Closes #137.