- From: Domenic Denicola <notifications@github.com>
- Date: Mon, 23 Apr 2018 15:31:11 +0000 (UTC)
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/917/383617735@github.com>
Looking at https://github.com/ricea/web-platform-tests/blob/f7aab0af8bf4ffc4aa24ce4bb5299b0a063ff8ef/streams/readable-byte-streams/constructor.js#L9 is a bit concerning. The logic is not very transparent. Additionally, it's interesting that we disallow some things but ignore others; e.g. we ignore autoAllocateChunkSize for non-byte streams, but disallow a size() in the strategy.
A variant that would make the most sense to me would be:
```js
op('get', 'cancel'),
op('validate', 'cancel'),
op('get', 'pull'),
op('validate', 'pull'),
op('get', 'start'),
op('validate', 'start'),
op('get', 'type'),
op('validate', 'type'),
op('get', 'autoAllocateChunkSize'), // *
op('tonumber', 'autoAllocateChunkSize'), // *
op('validate', 'autoAllocateChunkSize'), // *
op('get', 'size'), // **
op('validate', 'size'), // **
op('get', 'highWaterMark'),
op('tonumber', 'highWaterMark'),
op('validate', 'highWaterMark'),
```
Then
- * = either omit if type !== 'bytes', or omit the tonumber and change the validate to throw, or just omit the tonumber/validate
- ** = either omit if type === 'bytes', or change the validate to throw, or just omit the validate
The principles here are:
- left to right argument processing
- alphabetical within arguments
- type conversion/validation happens immediately after getting
It's worth noting that the semantics with * = omit the tonumber/validate and ** = omit the validate are then exactly what you'd get with Web IDL.
We'd then want to extend these principles to the other cases besides readable byte stream.
I realize this would be harder to factor, given that it would require logic that is currently in SetUpReadableByteStreamControllerFromUnderlyingSource to be put back in the constructor. So maybe it's not worth it. I'm totally happy to accept #922 and associated tests, and revisit this later if someone else complains. The more important thing is just picking an order, and aligning the reference implementation/tests together, and in that regard #922 suffices. But I thought it'd be good to write out my thoughts.
--
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/issues/917#issuecomment-383617735
Received on Monday, 23 April 2018 15:31:36 UTC