Skip to content

Commit dd0c925

Browse files
ronkorvingMyles Borins
ronkorving
authored and
Myles Borins
committed
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 <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Roman Reiss <me@silverwind.io>
1 parent 764df21 commit dd0c925

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/dgram.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ Socket.prototype.send = function(buffer,
252252

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

259258
offset = offset | 0;

0 commit comments

Comments
 (0)