Skip to content

Commit

Permalink
udp: remove a needless instanceof Buffer check
Browse files Browse the repository at this point in the history
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>

Conflicts:
	lib/dgram.js
  • Loading branch information
ronkorving authored and cjihrig committed Dec 16, 2015
1 parent 9ab669f commit 8c7b0cc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ Socket.prototype.send = function(buffer,

if (typeof buffer === 'string')
buffer = new Buffer(buffer);

if (!(buffer instanceof Buffer))
throw new TypeError('First argument must be a buffer or string.');
else if (!(buffer instanceof Buffer))
throw new TypeError('First argument must be a buffer or string');

offset = offset | 0;
if (offset < 0)
Expand Down

0 comments on commit 8c7b0cc

Please sign in to comment.