Re: [whatwg/encoding] Add Streams support (#72)

Here's a strawman proposal for the new IDL:
```idl
dictionary TextDecoderOptions {
  boolean fatal = false;
  boolean ignoreBOM = false;
};

dictionary TextDecodeOptions {
  boolean stream = false;
};

interface mixin HasEncoding {
  readonly attribute DOMString encoding;
};

interface mixin IsDecoder {
  readonly attribute boolean fatal;  
  readonly attribute boolean ignoreBOM;
};

IsDecoder includes HasEncoding;

[Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options),
 Exposed=(Window,Worker)]
interface TextDecoder {
  USVString decode(optional BufferSource input, optional TextDecodeOptions options);
};

TextDecoder includes IsDecoder;

[Constructor,
 Exposed=(Window,Worker)]
interface TextEncoder {
  [NewObject] Uint8Array encode(optional USVString input = "");
};

TextEncoder includes HasEncoding;

interface mixin GeneralTransformStream {
  readonly attribute ReadableStream readable;
  readonly attribute WritableStream writable;
};

[Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options),
 Exposed=(Window,Worker)]
interface TextDecoderStream {
};

TextDecoderStream includes IsDecoder;
TextDecoderStream includes GeneralTransformStream;

[Constructor,
 Exposed=(Window,Worker)]
interface TextEncoderStream {
};

TextEncoderStream includes HasEncoding;
TextEncoderStream includes GeneralTransformStream;
```
Correction welcome.

Questions:

- Is `HasEncoding` too trivial to be a mixin?
- Is it okay that all the members of TextEncoderStream and TextDecoderStream come from mixins?
- Shouild `readable` and `writable` be annotated `[SameObject]`?

-- 
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-393064499

Received on Wednesday, 30 May 2018 07:50:05 UTC