Re: [streams] How will ReadableByteStream work with seekable resources? (#253)

Re: https://github.com/whatwg/streams/issues/253#issuecomment-75790533 by Domenic,

Good point. If we can get the new ArrayBuffer reference but pointing to the same underlying buffer on completion, it's ok?

```
let newBuffer = await rbs.readInto(ab, 0, ab.byteLength);
// here, ab is neutered.
return newBuffer;
```

If readInto() may return when it finishes writing partial data,

```
let result = await rbs.readInto(ab, 0, ab.byteLength);
// here, ab is neutered.
return result;  // result.ab is a new reference. result.size is the number of bytes written
```

Or, adopt ArrayBufferView based approach,

```
let newView = await rbs.readInto(view);
// here, view is neutered.
return newView;
```

`newView` specifies the region to which data have been written. `newView` and `view` are different references, and `newView.buffer` and `view.buffer` are also different references. `view` and `view.buffer` are both neutered on `readInto()` call.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/253#issuecomment-75903137

Received on Wednesday, 25 February 2015 04:19:08 UTC