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

filipesilvaa picture filipesilvaa  路  3Comments

fanjunzhi picture fanjunzhi  路  3Comments

danialkhansari picture danialkhansari  路  3Comments

srl295 picture srl295  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments