Skip to content

Commit 8c7b0cc

Browse files
ronkorvingcjihrig
authored andcommitted
udp: remove a needless instanceof Buffer check
When a string is passed to udpsock.send, it is automatically converted to a Buffer. In that case, it is no longer needed to test whether or not the argument is a Buffer or not. PR-URL: #4301 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Conflicts: lib/dgram.js
1 parent 9ab669f commit 8c7b0cc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/dgram.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,8 @@ Socket.prototype.send = function(buffer,
252252

253253
if (typeof buffer === 'string')
254254
buffer = new Buffer(buffer);
255-
256-
if (!(buffer instanceof Buffer))
257-
throw new TypeError('First argument must be a buffer or string.');
255+
else if (!(buffer instanceof Buffer))
256+
throw new TypeError('First argument must be a buffer or string');
258257

259258
offset = offset | 0;
260259
if (offset < 0)

0 commit comments

Comments
 (0)