[whatwg/streams] Fix readable/writable file stream examples (PR #1191)

These examples weren't closing the filehandle correctly (they called `close` on a nonexistent `fd` variable, rather than calling the `fileHandle.close` method).

Also the ReadableStream example misused the `fileHandle.read` call: it was supplying an ArrayBuffer and v's byteOffset within the ArrayBuffer, but the API requires supplying v itself and an offset relative to v's start.

Also added the file offset `position` to that `fileHandle.read` call. There's no reason otherwise for the example to keep track of this. Alternatively, the argument could be supplied as null, and we just rely on implicit file positioning.

<!--
Thank you for contributing to the Streams Standard! Please describe the change you are making and complete the checklist below if your change is not editorial.
-->

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * …
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chrome: …
   * Firefox: …
   * Safari: …

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/1191


-- Commit Summary --

  * Fix readable/writable file stream examples

-- File Changes --

    M index.bs (9)

-- Patch Links --

https://github.com/whatwg/streams/pull/1191.patch

https://github.com/whatwg/streams/pull/1191.diff


-- 
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/1191

Received on Sunday, 28 November 2021 08:45:20 UTC