[streams] Convert readable stream pull() to promise-returning (#272)

See discussion in #185 for background.

This allows more convenient integration with promise-returning underlying source functions, removing the need for `.catch(error)` as seen in the modified example.

It also rationalizes the slightly-strange way in which pull() is mutexed based on whether enqueue() has been called: instead, it is now mutexed so as to not be called again until the previous iteration's promise has fulfilled. This gives more direct control to the underlying source, and allows them to deal more easily with cases where there are just no chunks to enqueue.

Although superficially it seems this may reduce performance for cases where underlying sources can enqueue many chunks synchronously, this is not actually the case, as can be seen from the modified test illustrating such a scenario. If an underlying source can enqueue multiple chunks synchronously, then it should just do so! It shouldn't wait to be pull()ed, as the previous test was doing.
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/272

-- Commit Summary --

  * Convert readable stream pull() to promise-returning

-- File Changes --

    M index.bs (50)
    M reference-implementation/lib/readable-stream-abstract-ops.js (23)
    M reference-implementation/lib/readable-stream.js (2)
    M reference-implementation/test/bad-underlying-sources.js (6)
    M reference-implementation/test/pipe-to.js (8)
    M reference-implementation/test/readable-stream.js (63)
    M reference-implementation/test/utils/sequential-rs.js (32)

-- Patch Links --

https://github.com/whatwg/streams/pull/272.patch
https://github.com/whatwg/streams/pull/272.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/272

Received on Tuesday, 27 January 2015 02:17:34 UTC