-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add method to read file into user given Uint8Array #83
Comments
This sounds very similar to what you would be able to do with a https://streams.spec.whatwg.org/#byob-reader-class right? I'm not necessarily against having similar functionality in FileReader as well, but I think eventually the streams API should be the one way to stream data from whatever source, so I'd be hesitant to add more functionality to FileReader. A somewhat sensible API to get a ReadableStream out of a Blob would seem like a much better solution to improving the ways you can read from blobs/files (note that you can already get a ReadableStream for a blob by wrapping the blob in a Response and calling its body method). |
See also #40 |
Readable stream with byob sounds kinda like what I'm looking for but since it's not a specific API I fear it will still internally perform copy. |
Until BYOB reader is supported by more browsers, this would be nice to have for use with SharedArrayBuffer. |
For me it is not clear how byob-streams will solve this problem. Please enlighten me on this issue! |
Fixed by #188 I'd say. |
Reading file contents into user supplied array avoids unnecessary copies. For example you can just get a pointer to an area in a WASM memory and directly read the file instead of first reading it into an useless ArrayBuffer and then doing a slow copy:
It also allows reading files while using minimal memory and allocations:
Doing the same with current APIs would allocate a ton of small ArrayBuffers...
The text was updated successfully, but these errors were encountered: