-
Notifications
You must be signed in to change notification settings - Fork 4
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
moz-chunked-arraybuffer vs. moz-chunked-text #13
Comments
I can't recall a strong design choice behind that one; however it does provide consistency with the
#12 (implemetning streaming binary protocols) would be implemented by pushing the 'to-text' decoding part into the (default) chunk parser.
It's not something I've benchmarked; might be a bit tricky to do so in a way that's not also benchmarking an underlying HTTP server (even when running locally) - would also be interested to see some concrete data :) |
For my users, I can't ignore browsers without if (root.TextDecoder) {
// parse ArrayBuffer
} else {
// parse text
}
Agreed! |
Instead of forcing parsers to handle both ArrayBuffers and text, another option would be to use the polyfill for the Encoding Living Standard's API. It's really large at 537K minified, so maybe we could get away with just the UTF8 version, which is 5.4K minified. |
It appears Safari and IE10+ support ArrayBuffers but not TextDecoder. How hard would it be for the parsers to handle ArrayBuffers without guaranteed availability of TextDecoder? |
How about this: the input to each parser is always a fetch('/big-data.csv').then(function(response) {
var reader = response.body.getReader();
...
}); This For browsers that support To get a stream of ArrayBuffers would require some browser-specific processing. For FF and IE10+, we'd just set XHR Does that sound reasonable? |
Actually for IE9, we could use something simpler like this to encode text to an ArrayBuffer, because WHATWG says the encoder must use UTF8:
(modified from here) Supporting IE9 would also require a polyfill for |
Thanks for the thought and time you have put into this @ariutta!
This sounds like an excellent suggestion; in the future we could always allow the caller to specify if they want to get bytes or text fed from the
It's not something I'm interested in doing (my target use-case only covers evergreen browsers) - hover I would be happy to add support in the future - library filesize is not really one of my primary drivers for this lib. Thanks again! |
Thanks for getting this library started, @jonnyreeves! For the parsers, the library jBinary looks interesting: "High-level API for working with binary data." |
I've started implementing these ideas here: It's not at all production-ready yet, but feel free to take a look! And you can even start integrating any or all of my code if you like, but just be warned that it needs much more testing. You'll see lots of |
I didn't change the API yet to pass a |
Looks good! Commented on the pull request. |
I was wondering why the responseType is
moz-chunked-arraybuffer
here instead ofmoz-chunked-text
. The array buffers are always converted to text (here and here). Are you are planning to use array buffers in a future version of this library? Or are array buffers better for communication over the wire?The text was updated successfully, but these errors were encountered: