From 8c7b0cc9773952979f07dbbfde1f172d58c7c0c1 Mon Sep 17 00:00:00 2001 From: ronkorving Date: Wed, 16 Dec 2015 11:09:13 +0900 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/4301 Reviewed-By: Colin Ihrig Reviewed-By: Brian White Reviewed-By: Roman Reiss Conflicts: lib/dgram.js --- lib/dgram.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index eaf84272d16284..a56e08f4a43dd7 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -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)