joyent/node — pull request #5899 by isaacs (2013-07-24 23:27:35+00:00)
Title: streams: Don't emit 'end' until read() past EOF

This prevents the following sort of thing from being confusing:

```javascript
stream.on('data', function() { console.error('got data'); });
stream.pause(); // stop reading

// turns out no data is available
stream.push(null);

// too late! 'end' is already emitted!
stream.on('end', function() { console.error('got end'); });
```

With this change, the `end` event is not emitted until you call `read()` *past* the EOF null. So, a paused stream will not swallow the `end` event and emit it before you `resume()` the stream.

cc: @davepacheco