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

> I think we do want to expose fatal and ignoreBOM so if we do a static method it'd have to expose those.

FWIW, if this is the case then the constructor version seems better. Part of the simplicity of the static method version is that it just returns a TransformStream.

If you need it to return something that's actually a TransformStream + extra properties, then you need a subclass, like TextEncoderTransformStream. But then you probably should just make that normally-constructible anyway, e.g. `new TextEncoderTransformStream({ fatal, ignoreBOM })`, instead of have a factory method, `TextEncoder.stream({ fatal, ignoreBOM })`, that magically constructs instances of TextEncoderTransformStream. So now you have two classes, TextEncoder and TextEncoderTransformStream, which both take and expose the same options and let you encode, but via different API surfaces.

>From this perspective, it seems reasonable to use a single-class version, where once you construct a TextEncoder, it both exposes the options you gave it, and has two non-overlapping APIs for encoding according to those options.

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

Received on Thursday, 22 March 2018 23:38:19 UTC