-
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
Feature/streams #20
Feature/streams #20
Conversation
cc @ariutta - sorry for the delay; hoping to start getting this nailed down now. I've gone for a slightly different API for the |
Thanks to @jimmywarting for the inspiration; the `xhrTransport` now makes use of the `web-streams-polyfill` to return a `ReadableStream` which allows us to emulate the `Response.body()` method from the `fetch` standard. Took this oppertunity to unify the xhr based implementations and make the transport detection be based on features rather than user-agent detection.
This branch now incorperate's @jimmywarting's ideas on using a One question that arises from this change is does providing a parser make sense, or should the library just become a |
You are kind of polyfilling the fetch api now? 😆 You should maybe make a PR to them :P |
I don't think you should parse the arrayBuffer to string. If it's going to work like fetch ReadableStream then parsing the response to text is, well kind of unexpected. The Stream api have something like a binary stream that is more friendly with memory allocation. Other libraries could take advantage of this such as jszip where they could "read into a ArrayBuffer allocation" The TextDecoder api will eventually have some Transform stream You can create another module that's more like a polyfill out of TextDecoder transform. I almost did it with web-byline Beside you don't want to parse a binary and you only get one ReadableStream back, so how do you know if you should parse it? you don't want to do it with a image... and it don't look good with an option such as Think it's just better to pipe it |
OK - taken a very different approach over the last few days and have pulled the guts of this library out into a new library: https://github.com/jonnyreeves/fetch-readablestream I am unsure what to do about this library - it feels a touch redundant now as it just provides a defaultParser implementation which is trivial to re-create in user code, eg: https://github.com/jonnyreeves/fetch-readablestream/blob/release/v0.1.0/test/integ/util.js |
WIP implementation of stream-based parsers, see #16.