PR-URL: https://github.com/nodejs/node/pull/11582
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
James M Snell 2017-02-25 22:16:57 -08:00
Родитель c8acd08a37
Коммит 910a8998fb
2 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -34,6 +34,8 @@ var StringDecoder;
util.inherits(Readable, Stream);
const kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
function prependListener(emitter, event, fn) {
// Sadly this is not cacheable as some libraries bundle their own
// event emitter implementation with them.
@ -828,10 +830,9 @@ Readable.prototype.wrap = function(stream) {
}
// proxy certain important events.
const events = ['error', 'close', 'destroy', 'pause', 'resume'];
events.forEach(function(ev) {
stream.on(ev, self.emit.bind(self, ev));
});
for (var n = 0; n < kProxyEvents.length; n++) {
stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
}
// when we try to consume some more bytes, simply unpause the
// underlying stream.

Просмотреть файл

@ -118,9 +118,8 @@ StreamWrap.prototype.doWrite = function doWrite(req, bufs) {
const item = self._enqueue('write', req);
self.stream.cork();
bufs.forEach(function(buf) {
self.stream.write(buf, done);
});
for (var n = 0; n < bufs.length; n++)
self.stream.write(bufs[n], done);
self.stream.uncork();
function done(err) {