Node: stream: Readable.from with null

Created on 14 Apr 2020  路  2Comments  路  Source: nodejs/node

Reading through the Readable.from code is seems to me that the semantics of using Readable.from on a generator which yields null is not entirely clear.

Should we add a check for value == null and throw?

  async function next() {
    try {
      const { value, done } = await iterator.next();
      if (done) {
        readable.push(null);
      } else if (readable.push(await value)) { // Hm, push(null) and then next()?
        next();
      } else {
        reading = false;
      }
    } catch (err) {
      readable.destroy(err);
    }
  }

Might also want to be a bit more explicit in the docs about this?

Most helpful comment

This makes sense. @ronag can I work on this?

All 2 comments

This makes sense. @ronag can I work on this?

Go for it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cong88 picture cong88  路  3Comments

Brekmister picture Brekmister  路  3Comments

jmichae3 picture jmichae3  路  3Comments

filipesilvaa picture filipesilvaa  路  3Comments

dfahlander picture dfahlander  路  3Comments