RE: Overlap between StreamReader and FileReader

From: Anne van Kesteren [annevk@annevk.nl]

> Stream.prototype.readType takes an enumerated string value which is "arraybuffer" (default) or "text".

> Stream.prototype.read returns a promise fulfilled with the type of value requested.


I believe this is somewhat similar to how Node streams have settled. Their API is that you call `stream.setEncoding('utf-8')` and then calling `.read(n)` will return a string of at most n characters. By default, there is no encoding set, and calling `.read(n)` will return n bytes in a buffer.

In this way, the encoding is a stateful aspect of the stream itself. I don't think there's a way to get around this, without ending up with dangling half-character bytes hanging around.

Received on Wednesday, 31 July 2013 16:04:24 UTC