- From: Adam Rice <notifications@github.com>
- Date: Mon, 03 Oct 2016 20:08:02 -0700
- To: whatwg/encoding <encoding@noreply.github.com>
- Message-ID: <whatwg/encoding/issues/72/251284703@github.com>
I think the first issue to resolve is whether the API should be ```javascript var stringReadable = byteReadable.pipeThrough(TextDecoder.stream()); ``` or ```javascript var stringReadable = byteReadable.pipeThrough(new TextDecoder()); ``` My spec patch currently implements the first one. The second one is clearly more readable, but it makes it unclear what this does: ```javascript var decoder = new TextDecoder(); decoder.decode(new Uint8Array([0xE0]), {stream: true}); setTimeout(() => decoder.decode(new Uint8Array([0xA0]), {stream: true}), 1); var stringReadable = byteReadable.pipeThrough(decoder); ``` @jakearchibald in https://github.com/whatwg/encoding/commit/9224c4cad81fd5720306fe79241cf04b5526a3f0#commitcomment-19186596 suggested that `decode()` should throw if either the readable or writable streams are locked. This gives predictable behaviour: in the above example, the first call to `decode()` would work, and the `byteReadable` stream would have to start with a byte in the range 0xA0 to 0xBF. The second call to `decode()` would throw, because `pipeThrough()` has locked the writable member of `decoder`. I expressed some other concerns about the second option in https://github.com/whatwg/encoding/commit/9224c4cad81fd5720306fe79241cf04b5526a3f0#commitcomment-19186596. -- 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/encoding/issues/72#issuecomment-251284703
Received on Tuesday, 4 October 2016 03:08:33 UTC