Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream,net: slightly more consistent typechecking #17644

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ function validChunk(stream, state, chunk, cb) {

if (chunk === null) {
er = new errors.TypeError('ERR_STREAM_NULL_VALUES');
} else if (typeof chunk !== 'string' &&
chunk !== undefined &&
!state.objectMode) {
} else if (typeof chunk !== 'string' && !state.objectMode) {
er = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'chunk',
['string', 'Buffer']);
}
Expand Down
11 changes: 0 additions & 11 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,17 +701,6 @@ protoGetter('localPort', function localPort() {
});


Socket.prototype.write = function(chunk, encoding, cb) {
if (typeof chunk !== 'string' && !(chunk instanceof Buffer)) {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
'chunk',
['string', 'Buffer'],
chunk);
}
return stream.Duplex.prototype.write.apply(this, arguments);
};


Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
// If we are still connecting, then buffer this for later.
// The Writable logic will buffer up any more writes while
Expand Down