Re: [whatwg/streams] Fix readable byte stream example (#1080)

@nidhijaju commented on this pull request.



> -   .then(buffer => console.log("The first 1024 bytes:", buffer))
-   .catch(e => console.error("Something went wrong!", e));
-
- function readInto(buffer, offset = 0) {
-   if (offset === buffer.byteLength) {
-     return Promise.resolve(buffer);
-   }
+ const buffer = await readInto(startingAB);
+ console.log("The first 1024 bytes: ", buffer);
+
+ async function readInto(buffer) {
+   let offset = 0;
+   let view;
+   let done;
+
+   do {

That's a good point! I've just changed it to that in the last commit. Thank you!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1080#discussion_r513132803

Received on Wednesday, 28 October 2020 01:53:59 UTC