diff options
Diffstat (limited to 'lib/dgram.js')
-rw-r--r-- | lib/dgram.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/dgram.js b/lib/dgram.js index 7f279980cf..1ac5c27c38 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -91,7 +91,7 @@ function newHandle(type) { exports._createSocketHandle = function(address, port, addressType, fd) { // Opening an existing fd is not supported for UDP handles. - assert(typeof fd !== 'number' || fd < 0); + assert(!IS_NUMBER(fd) || fd < 0); var handle = newHandle(addressType); @@ -119,7 +119,7 @@ function Socket(type, listener) { this.type = type; this.fd = null; // compatibility hack - if (typeof listener === 'function') + if (IS_FUNCTION(listener)) this.on('message', listener); } util.inherits(Socket, events.EventEmitter); @@ -165,7 +165,7 @@ Socket.prototype.bind = function(/*port, address, callback*/) { this._bindState = BIND_STATE_BINDING; - if (typeof arguments[arguments.length - 1] === 'function') + if (IS_FUNCTION(arguments[arguments.length - 1])) self.once('listening', arguments[arguments.length - 1]); var UDP = process.binding('udp_wrap').UDP; @@ -177,7 +177,7 @@ Socket.prototype.bind = function(/*port, address, callback*/) { var port = arguments[0]; var address = arguments[1]; - if (typeof address === 'function') address = ''; // a.k.a. "any address" + if (IS_FUNCTION(address)) address = ''; // a.k.a. "any address" // resolve address first self._handle.lookup(address, function(err, ip) { @@ -225,10 +225,10 @@ Socket.prototype.sendto = function(buffer, port, address, callback) { - if (typeof offset !== 'number' || typeof length !== 'number') + if (!IS_NUMBER(offset) || !IS_NUMBER(length)) throw new Error('send takes offset and length as args 2 and 3'); - if (typeof address !== 'string') + if (!IS_STRING(address)) throw new Error(this.type + ' sockets must send to port, address'); this.send(buffer, offset, length, port, address, callback); @@ -243,7 +243,7 @@ Socket.prototype.send = function(buffer, callback) { var self = this; - if (!Buffer.isBuffer(buffer)) + if (!IS_BUFFER(buffer)) throw new TypeError('First argument must be a buffer object.'); if (offset >= buffer.length) @@ -335,7 +335,7 @@ Socket.prototype.setBroadcast = function(arg) { Socket.prototype.setTTL = function(arg) { - if (typeof arg !== 'number') { + if (!IS_NUMBER(arg)) { throw new TypeError('Argument must be a number'); } @@ -349,7 +349,7 @@ Socket.prototype.setTTL = function(arg) { Socket.prototype.setMulticastTTL = function(arg) { - if (typeof arg !== 'number') { + if (!IS_NUMBER(arg)) { throw new TypeError('Argument must be a number'); } |