summaryrefslogtreecommitdiff
path: root/lib/_stream_wrap.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-06-22 02:38:41 +0200
committerMatteo Collina <hello@matteocollina.com>2017-06-29 18:03:54 +0200
commit1b54371c50cd6a67f22f6ec0db53bac3917387e5 (patch)
tree9175888abe32e1c3aacf95b39f0de4876f2b21c7 /lib/_stream_wrap.js
parenta1ecdcfb154ec79db4da595ca85ce75f9f759c6a (diff)
downloadandroid-node-v8-1b54371c50cd6a67f22f6ec0db53bac3917387e5.tar.gz
android-node-v8-1b54371c50cd6a67f22f6ec0db53bac3917387e5.tar.bz2
android-node-v8-1b54371c50cd6a67f22f6ec0db53bac3917387e5.zip
stream: use more explicit statements
Using objectMode with stream_wrap has not worked properly before and would end in an error. Therefore prohibit the usage of objectMode alltogether. This also improves the handling performance due to the cheaper chunk check and by using explicit statements as they produce better code from the compiler. PR-URL: https://github.com/nodejs/node/pull/13863 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/_stream_wrap.js')
-rw-r--r--lib/_stream_wrap.js7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/_stream_wrap.js b/lib/_stream_wrap.js
index 4b92fb6453..00e6de2fd2 100644
--- a/lib/_stream_wrap.js
+++ b/lib/_stream_wrap.js
@@ -4,9 +4,6 @@ const assert = require('assert');
const util = require('util');
const Socket = require('net').Socket;
const JSStream = process.binding('js_stream').JSStream;
-// TODO(bmeurer): Change this back to const once hole checks are
-// properly optimized away early in Ignition+TurboFan.
-var Buffer = require('buffer').Buffer;
const uv = process.binding('uv');
const debug = util.debuglog('stream_wrap');
const errors = require('internal/errors');
@@ -47,12 +44,12 @@ function StreamWrap(stream) {
self.emit('error', err);
});
this.stream.on('data', function ondata(chunk) {
- if (!(chunk instanceof Buffer)) {
+ if (typeof chunk === 'string' || this._readableState.objectMode === true) {
// Make sure that no further `data` events will happen
this.pause();
this.removeListener('data', ondata);
- self.emit('error', new errors.Error('ERR_STREAM_HAS_STRINGDECODER'));
+ self.emit('error', new errors.Error('ERR_STREAM_WRAP'));
return;
}