Skip to content

Commit eee9dc7

Browse files
committed
Revert "stream: add bytesRead property for readable"
This reverts commit bfb2cd0. The bytesRead property, as implemented, tracks characters instead of bytes when using an identity encoding. Refs: #4372 PR-URL: #4746 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ff64a4c commit eee9dc7

File tree

4 files changed

+5
-127
lines changed

4 files changed

+5
-127
lines changed

doc/api/stream.markdown

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,6 @@ readable: null
250250
end
251251
```
252252

253-
254-
#### readable.bytesRead
255-
256-
The amount of read bytes. If `objectMode` is `true`, the value is 0 always.
257-
258253
#### readable.isPaused()
259254

260255
* Return: `Boolean`

lib/_stream_readable.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ function Readable(options) {
8383

8484
this._readableState = new ReadableState(options, this);
8585

86-
this.bytesRead = 0;
87-
8886
// legacy
8987
this.readable = true;
9088

@@ -137,7 +135,6 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
137135
var e = new Error('stream.unshift() after end event');
138136
stream.emit('error', e);
139137
} else {
140-
stream.bytesRead += state.objectMode ? 0 : chunk.length;
141138
if (state.decoder && !addToFront && !encoding)
142139
chunk = state.decoder.write(chunk);
143140

lib/net.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ exports._normalizeConnectArgs = normalizeConnectArgs;
9191
// called when creating new Socket, or when re-using a closed Socket
9292
function initSocketHandle(self) {
9393
self.destroyed = false;
94+
self.bytesRead = 0;
9495
self._bytesDispatched = 0;
9596
self._sockname = null;
9697

@@ -514,6 +515,10 @@ function onread(nread, buffer) {
514515
// will prevent this from being called again until _read() gets
515516
// called again.
516517

518+
// if it's not enough data, we'll just call handle.readStart()
519+
// again right away.
520+
self.bytesRead += nread;
521+
517522
// Optimization: emit the original buffer with end points
518523
var ret = self.push(buffer);
519524

test/parallel/test-stream2-readable-bytesread.js

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)