diff options
Diffstat (limited to 'lib/dgram.js')
-rw-r--r-- | lib/dgram.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/dgram.js b/lib/dgram.js index cb20c4499a..e032a6f7fd 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -561,16 +561,19 @@ Socket.prototype.send = function(buffer, port = offset; address = length; } - } else if (typeof length === 'number') { - buffer = sliceBuffer(buffer, offset, length); - if (typeof port === 'function') { - callback = port; - port = null; - } else if (port || address) { - throw new ERR_SOCKET_DGRAM_IS_CONNECTED(); - } } else { - callback = offset; + if (typeof length === 'number') { + buffer = sliceBuffer(buffer, offset, length); + if (typeof port === 'function') { + callback = port; + port = null; + } + } else { + callback = offset; + } + + if (port || address) + throw new ERR_SOCKET_DGRAM_IS_CONNECTED(); } if (!Array.isArray(buffer)) { |