-
Notifications
You must be signed in to change notification settings - Fork 164
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
type of Chunk.value #410
Comments
It is whatever type the creator of the stream wants it to be. |
It can be multiple types in the same stream too. Each chunk can be different, if that is what the creator wants. |
Ok so that means that functions returning a Chunk should specify what the exact type of the Chunk is I suppose. I am using the Fetch API's fetch method which returns a Promise of a Response, which contains a Presumably they should state in their documentation what the type of the chunks returned by the ReadableStream is right? ( It would make it a bit easier to read the docs and use the APIs ). Hmm it looks like the Response.body method says:
So I suppose that means the content of the chunk contains bytes, but it is not clear that this means that all chunks will be |
https://fetch.spec.whatwg.org/ may help clarify:
|
https://fetch.spec.whatwg.org/#concept-body you've pointed in this sentence is not Response.body. It's a concept body associated with a concept request or a concept response. You should look at https://fetch.spec.whatwg.org/#dom-response-body which actually specifies what the JavaScript interface Response.body is. It leads you to the text @domenic just mentioned above. (/cc @yutakahirano) |
Ah I see there is a note:
So I suppose that's what I was missing, as I imagine that would state that a That's close to my suggestion. Though you'd avoid having to create new types of objects by developing a generics style notation for the documentation. |
ReadableByteStream is not just a ReadableStream with Uint8Array chunks in it. ReadableByteStream has more functionality that is not specified in ReadableStream to allow efficient handling of bytes (though we're discussing if we can merge them at #379). |
IDL Is not for documentation (nor are specs in general, really). MDN is probably a better place for that. |
Ya |
@bblfish in that case you'd better learn how to read specs, despite them not being written as documentation for users. |
@domenic I am doing my best, and I am sure you are too. |
Hi,
how is one meant to know what the value of a chunk is going to be? Does that depend on the function that returns chunks? The specification says in ¶2. Model:
By printing out the value I seem to have at one point found that it was an Array of bytes ( but I am no longer sure), at another time a Uint8Array which is a form of TypedArray.
If one can always treat the
chunk.value
as aUint8Array
would it not be best to state that this is what it returns?The text was updated successfully, but these errors were encountered: