Skip to content

stream: readableDidRead if data has been read

Only readableDidRead if there actually has been data read.

We have a slight conflict of use case here:

  1. If user has intention of reading, e.g. used by http to know if it's safe to dump. (https://github.com/nodejs/node/blob/master/lib/_http_server.js#L805-L806)
  2. If user wants to know if data has been read and whether or not it is possible to get all data, for e.g. json parsing. (https://github.com/nodejs/node/pull/39520/files#diff-040c1f5a53844e600d40b33c4624f1fe39fcf2f8d62c76ca3fc5ea5442231469R1366-R1368)

1, If resume(), read(), pipe() has been called or 'data' or 'readable' listener exists. 2, If read() has returned data or 'end' or 'data' has been emitted.

Do we need two separate properties and if so what should they be called?

readableDidRead, readableDisturbed, readableUsed or readableReading?

If we only want/need one of them I would prefer 2.

Merge request reports

Loading