W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2013

Re: Overlap between StreamReader and FileReader

From: Takeshi Yoshino <tyoshino@google.com>
Date: Thu, 26 Sep 2013 13:17:41 +0900
Message-ID: <CAH9hSJbwYWcoqrTk+aipeosfK4cz3MFrjHzoC2hb1fr4NYv=AA@mail.gmail.com>
To: Aymeric Vitte <vitteaymeric@gmail.com>
Cc: Isaac Schlueter <i@izs.me>, Jonas Sicking <jonas@sicking.cc>, Austin William Wright <aaa@bzfx.net>, Domenic Denicola <domenic@domenicdenicola.com>, "public-webapps@w3.org" <public-webapps@w3.org>
As we don't see any strong demand for flow control and sync read
functionality, I've revised the proposal.

Though we can separate state/error signaling from Stream and keep them done
by each API (e.g. XHR) as Aymeric said, EoF signal still needs to be
conveyed through Stream.


enum StreamReadType {

interface StreamConsumeResult {
  readonly attribute boolean eof;
  readonly any data;
  readonly unsigned long long size;

[Constructor(optional DOMString mime)]
interface Stream {
  readonly attribute DOMString type;  // MIME type

  // Rejected on error. No more write op shouldn't be made.
  // Fulfilled when the write completes. It doesn't guarantee that the
written data has been
  // read out successfully.
  // The contents of ArrayBufferView must not be modified until the promise
is fulfilled.
  // Fulfill may be delayed when the Stream considers itself to be full.
  // write(), close() must not be called again until the Promise of the
last write() is fulfilled.
  Promise<void> write((DOMString or ArrayBufferView or Blob)? data);
  void close();

  attribute StreamReadType readType;
  attribute DOMString readEncoding;

  // read(), skip(), pipe() must not be called again until the Promise of
the last read(), skip(), pipe() is fulfilled.

  // Rejected on error. No more read op shouldn't be made.
  // If size is specified,
  // - if EoF: fulfilled with data up to EoF
  // - otherwise: fulfilled with data of size bytes
  // If size is omitted, (all or part of) data available for read now will
be returned.
  // If readType is set to text, size of the result may be smaller than the
value specified for the size argument.
  Promise<StreamConsumeResult> read(optional [Clamp] long long size);

  // Rejected on error. Fulfilled on completion.
  // .data of result is not used. .size of result is the skipped amount.
  Promise<StreamConsumeResult> skip([Clamp] long long size);  // .data is
skipped size

  // Rejected on error. Fulfilled on completion.
  // If size is omitted, transfer until EoF is encountered.
  // .data of result is not used. .size of result is the size of data
  Promise<StreamConsumeResult> pipe(Stream destination, optional [Clamp]
long long size);
Received on Thursday, 26 September 2013 04:18:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:13 UTC