Skip to content

stream: update comment for needMoreData #19695

@mcollina

Description

@mcollina
  • Version: master
  • Platform: all
  • Subsystem: streams

// if it's past the high water mark, we can push in some more.
// Also, if we have no data yet, we can stand some
// more bytes. This is to work around cases where hwm=0,
// such as the repl. Also, if the push() triggered a
// readable event, and the user called read(largeNumber) such that
// needReadable was set, then we ought to push more, so that another
// 'readable' event will be triggered.
function needMoreData(state) {
return !state.ended &&
(state.length < state.highWaterMark ||
state.length === 0);
}
comment is out of date (ref. #19613 (comment)).

Specifically it states:

I think that comment is actually wrong. It says

if it's past the high water mark, we can push in some more.

However it has a check (simplified) as:

return state.length < state.highWaterMark

Which will return true if we are below the watermark.

This would be a good issue for someone willing to learn more about streams.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions