diff --git a/lib/_debugger.js b/lib/_debugger.js index ed71c668f316b7..beed1fa2fbdccc 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -173,7 +173,7 @@ Client.prototype._addHandle = function(desc) { this.handles[desc.handle] = desc; - if (desc.type == 'script') { + if (desc.type === 'script') { this._addScript(desc); } }; @@ -186,7 +186,7 @@ Client.prototype._addScript = function(desc) { this.scripts[desc.id] = desc; if (desc.name) { desc.isNative = (desc.name.replace('.js', '') in natives) || - desc.name == 'node.js'; + desc.name === 'node.js'; } }; @@ -201,7 +201,7 @@ Client.prototype._onResponse = function(res) { index = -1; this._reqCallbacks.some(function(fn, i) { - if (fn.request_seq == res.body.request_seq) { + if (fn.request_seq === res.body.request_seq) { cb = fn; index = i; return true; @@ -211,25 +211,25 @@ Client.prototype._onResponse = function(res) { var self = this; var handled = false; - if (res.headers.Type == 'connect') { + if (res.headers.Type === 'connect') { // Request a list of scripts for our own storage. self.reqScripts(); self.emit('ready'); handled = true; - } else if (res.body && res.body.event == 'break') { + } else if (res.body && res.body.event === 'break') { this.emit('break', res.body); handled = true; - } else if (res.body && res.body.event == 'exception') { + } else if (res.body && res.body.event === 'exception') { this.emit('exception', res.body); handled = true; - } else if (res.body && res.body.event == 'afterCompile') { + } else if (res.body && res.body.event === 'afterCompile') { this._addHandle(res.body.body.script); handled = true; - } else if (res.body && res.body.event == 'scriptCollected') { + } else if (res.body && res.body.event === 'scriptCollected') { // ??? this._removeScript(res.body.body.script); handled = true; @@ -327,7 +327,7 @@ Client.prototype.reqScopes = function(cb) { Client.prototype.reqEval = function(expression, cb) { var self = this; - if (this.currentFrame == NO_FRAME) { + if (this.currentFrame === NO_FRAME) { // Only need to eval in global scope. this.reqFrameEval(expression, NO_FRAME, cb); return; @@ -357,7 +357,7 @@ Client.prototype.reqEval = function(expression, cb) { // Finds the first scope in the array in which the expression evals. Client.prototype._reqFramesEval = function(expression, evalFrames, cb) { - if (evalFrames.length == 0) { + if (evalFrames.length === 0) { // Just eval in global scope. this.reqFrameEval(expression, NO_FRAME, cb); return; @@ -381,7 +381,7 @@ Client.prototype.reqFrameEval = function(expression, frame, cb) { arguments: { expression: expression } }; - if (frame == NO_FRAME) { + if (frame === NO_FRAME) { req.arguments.global = true; } else { req.arguments.frame = frame; @@ -528,9 +528,9 @@ Client.prototype.mirrorObject = function(handle, depth, cb) { var mirror, waiting = 1; - if (handle.className == 'Array') { + if (handle.className === 'Array') { mirror = []; - } else if (handle.className == 'Date') { + } else if (handle.className === 'Date') { mirror = new Date(handle.value); } else { mirror = {}; @@ -1096,14 +1096,14 @@ Interface.prototype.list = function(delta) { var lineno = res.fromLine + i + 1; if (lineno < from || lineno > to) continue; - var current = lineno == 1 + client.currentSourceLine, + var current = lineno === 1 + client.currentSourceLine, breakpoint = client.breakpoints.some(function(bp) { return (bp.scriptReq === client.currentScript || bp.script === client.currentScript) && - bp.line == lineno; + bp.line === lineno; }); - if (lineno == 1) { + if (lineno === 1) { // The first line needs to have the module wrapper filtered out of // it. var wrapper = Module.wrapper[0]; @@ -1150,7 +1150,7 @@ Interface.prototype.backtrace = function() { return; } - if (bt.totalFrames == 0) { + if (bt.totalFrames === 0) { self.print('(empty stack)'); } else { var trace = [], @@ -1192,10 +1192,10 @@ Interface.prototype.scripts = function() { var script = client.scripts[id]; if (script !== null && typeof script === 'object' && script.name) { if (displayNatives || - script.name == client.currentScript || + script.name === client.currentScript || !script.isNative) { scripts.push( - (script.name == client.currentScript ? '* ' : ' ') + + (script.name === client.currentScript ? '* ' : ' ') + id + ': ' + path.basename(script.name) ); @@ -1354,7 +1354,7 @@ Interface.prototype.setBreakpoint = function(script, line, }; } else { // setBreakpoint('scriptname') - if (script != +script && !this.client.scripts[script]) { + if (script !== +script && !this.client.scripts[script]) { var scripts = this.client.scripts; for (var id in scripts) { if (scripts[id] && diff --git a/lib/_http_server.js b/lib/_http_server.js index 1a4bd7555a5ccb..491798723ef224 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -464,7 +464,7 @@ function connectionListener(socket) { } if (req.headers.expect !== undefined && - (req.httpVersionMajor == 1 && req.httpVersionMinor == 1) && + (req.httpVersionMajor === 1 && req.httpVersionMinor === 1) && continueExpression.test(req.headers['expect'])) { res._expect_continue = true; if (EventEmitter.listenerCount(self, 'checkContinue') > 0) { diff --git a/lib/_linklist.js b/lib/_linklist.js index 02186cfedcb9f6..d93c1651522bde 100644 --- a/lib/_linklist.js +++ b/lib/_linklist.js @@ -9,7 +9,7 @@ exports.init = init; // show the most idle item function peek(list) { - if (list._idlePrev == list) return null; + if (list._idlePrev === list) return null; return list._idlePrev; } exports.peek = peek; diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js index 8ff428e11ffed0..d6b627f7fad875 100644 --- a/lib/_stream_transform.js +++ b/lib/_stream_transform.js @@ -183,7 +183,7 @@ function done(stream, er) { var ts = stream._transformState; if (ws.length) - throw new Error('calling transform done when ws.length != 0'); + throw new Error('calling transform done when ws.length !== 0'); if (ts.transforming) throw new Error('calling transform done when still transforming'); diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index b5d1899480bf46..cab34e2a25f99c 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -512,7 +512,7 @@ TLSSocket.prototype.renegotiate = function(options, callback) { }; TLSSocket.prototype.setMaxSendFragment = function setMaxSendFragment(size) { - return this._handle.setMaxSendFragment(size) == 1; + return this._handle.setMaxSendFragment(size) === 1; }; TLSSocket.prototype.getTLSTicket = function getTLSTicket() { diff --git a/lib/assert.js b/lib/assert.js index ea142ed01f8f6e..e501db85e73f9b 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -164,7 +164,7 @@ function _deepEqual(actual, expected, strict) { actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase; - // 7.4. Other pairs that do not both pass typeof value == 'object', + // 7.4. Other pairs that do not both pass typeof value === 'object', // equivalence is determined by ==. } else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) { @@ -182,7 +182,7 @@ function _deepEqual(actual, expected, strict) { } function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; + return Object.prototype.toString.call(object) === '[object Arguments]'; } function objEquiv(a, b, strict) { @@ -266,7 +266,7 @@ function expectedException(actual, expected) { return false; } - if (Object.prototype.toString.call(expected) == '[object RegExp]') { + if (Object.prototype.toString.call(expected) === '[object RegExp]') { return expected.test(actual); } else if (actual instanceof expected) { return true; diff --git a/lib/buffer.js b/lib/buffer.js index 403c344bdbe9c8..54605dc6d1f754 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -105,7 +105,7 @@ function fromObject(obj) { return b; } - if (obj == null) { + if (obj === null || obj === undefined) { throw new TypeError('must start with number, buffer, array or string'); } diff --git a/lib/child_process.js b/lib/child_process.js index 57a8601df59a98..6933d344e093f2 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -383,7 +383,7 @@ function spawnSync(/*file, args, options*/) { // We may want to pass data in on any given fd, ensure it is a valid buffer for (i = 0; i < options.stdio.length; i++) { var input = options.stdio[i] && options.stdio[i].input; - if (input != null) { + if (input !== null && input !== undefined) { var pipe = options.stdio[i] = util._extend({}, options.stdio[i]); if (Buffer.isBuffer(input)) pipe.input = input; diff --git a/lib/cluster.js b/lib/cluster.js index cbccd02605cb67..81a88d8920b263 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -48,7 +48,11 @@ Worker.prototype.send = function() { }; Worker.prototype.isDead = function isDead() { - return this.process.exitCode != null || this.process.signalCode != null; + var exitCode = this.process.exitCode; + var signalCode = this.process.signalCode; + + return (exitCode !== null && exitCode !== undefined) || + (signalCode !== null && signalCode !== undefined); }; Worker.prototype.isConnected = function isConnected() { diff --git a/lib/dgram.js b/lib/dgram.js index b7bb7d3d703eb1..9093492748bf84 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -39,13 +39,13 @@ function lookup6(address, callback) { function newHandle(type) { - if (type == 'udp4') { + if (type === 'udp4') { var handle = new UDP(); handle.lookup = lookup4; return handle; } - if (type == 'udp6') { + if (type === 'udp6') { var handle = new UDP(); handle.lookup = lookup6; handle.bind = handle.bind6; @@ -53,7 +53,7 @@ function newHandle(type) { return handle; } - if (type == 'unix_dgram') + if (type === 'unix_dgram') throw new Error('unix_dgram sockets are not supported any more.'); throw new Error('Bad socket type specified. Valid types are: udp4, udp6'); @@ -139,7 +139,7 @@ Socket.prototype.bind = function(port /*, address, callback*/) { self._healthCheck(); - if (this._bindState != BIND_STATE_UNBOUND) + if (this._bindState !== BIND_STATE_UNBOUND) throw new Error('Socket is already bound'); this._bindState = BIND_STATE_BINDING; @@ -253,7 +253,7 @@ Socket.prototype.send = function(buffer, if (offset < 0) throw new RangeError('Offset should be >= 0'); - if ((length == 0 && offset > buffer.length) || + if ((length === 0 && offset > buffer.length) || (length > 0 && offset >= buffer.length)) throw new RangeError('Offset into buffer too large'); @@ -277,12 +277,12 @@ Socket.prototype.send = function(buffer, self._healthCheck(); - if (self._bindState == BIND_STATE_UNBOUND) + if (self._bindState === BIND_STATE_UNBOUND) self.bind({port: 0, exclusive: true}, null); // If the socket hasn't been bound yet, push the outbound packet onto the // send queue and send after binding is complete. - if (self._bindState != BIND_STATE_BOUND) { + if (self._bindState !== BIND_STATE_BOUND) { // If the send queue hasn't been initialized yet, do it, and install an // event handler that flushes the send queue after binding is done. if (!self._sendQueue) { diff --git a/lib/events.js b/lib/events.js index 3ea798b3bdb01a..ccfe9dcba863bb 100644 --- a/lib/events.js +++ b/lib/events.js @@ -121,7 +121,7 @@ EventEmitter.prototype.emit = function emit(type) { events = this._events; if (events) - doError = (doError && events.error == null); + doError = doError && (events.error === null || events.error === undefined); else if (!doError) return false; diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index c6bb41ffdeb544..9ee2679eddc794 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -215,7 +215,7 @@ util.inherits(ChildProcess, EventEmitter); function flushStdio(subprocess) { - if (subprocess.stdio == null) return; + if (subprocess.stdio === null || subprocess.stdio === undefined) return; subprocess.stdio.forEach(function(stream, fd, stdio) { if (!stream || !stream.readable || stream._consuming) return; @@ -760,7 +760,7 @@ function getSocketList(type, slave, key) { function maybeClose(subprocess) { subprocess._closesGot++; - if (subprocess._closesGot == subprocess._closesNeeded) { + if (subprocess._closesGot === subprocess._closesNeeded) { subprocess.emit('close', subprocess.exitCode, subprocess.signalCode); } } diff --git a/lib/net.js b/lib/net.js index 10e789678440fd..edaf85f3961e5d 100644 --- a/lib/net.js +++ b/lib/net.js @@ -127,7 +127,7 @@ function Socket(options) { } else if (options.fd !== undefined) { this._handle = createHandle(options.fd); this._handle.open(options.fd); - if ((options.fd == 1 || options.fd == 2) && + if ((options.fd === 1 || options.fd === 2) && (this._handle instanceof Pipe) && process.platform === 'win32') { // Make stdout and stderr blocking on Windows @@ -501,7 +501,7 @@ Socket.prototype.destroy = function(exception) { function onread(nread, buffer) { var handle = this; var self = handle.owner; - assert(handle === self._handle, 'handle != self._handle'); + assert(handle === self._handle, 'handle !== self._handle'); self._unrefTimer(); @@ -678,7 +678,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) { // If it was entirely flushed, we can write some more right now. // However, if more is left in the queue, then wait until that clears. - if (req.async && this._handle.writeQueueSize != 0) + if (req.async && this._handle.writeQueueSize !== 0) req.cb = cb; else cb(); @@ -1037,7 +1037,7 @@ function afterConnect(status, handle, req, readable, writable) { self._connecting = false; self._sockname = null; - if (status == 0) { + if (status === 0) { self.readable = readable; self.writable = writable; self._unrefTimer(); diff --git a/lib/path.js b/lib/path.js index 78c61579ec0fc8..4bcb2b3672091c 100644 --- a/lib/path.js +++ b/lib/path.js @@ -277,7 +277,7 @@ win32.relative = function(from, to) { } } - if (samePartsLength == 0) { + if (samePartsLength === 0) { return to; } diff --git a/lib/punycode.js b/lib/punycode.js index 51aa75132937d5..5024ec9369317d 100644 --- a/lib/punycode.js +++ b/lib/punycode.js @@ -2,11 +2,11 @@ ;(function(root) { /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && + var freeExports = typeof exports === 'object' && exports && !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && + var freeModule = typeof module === 'object' && module && !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; + var freeGlobal = typeof global === 'object' && global; if ( freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || @@ -134,7 +134,7 @@ if (value >= 0xD800 && value <= 0xDBFF && counter < length) { // high surrogate, and there is a next character extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate + if ((extra & 0xFC00) === 0xDC00) { // low surrogate output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); } else { // unmatched surrogate; only append this code unit, in case the next @@ -206,7 +206,7 @@ function digitToBasic(digit, flag) { // 0..25 map to ASCII a..z or A..Z // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + return digit + 22 + 75 * (digit < 26) - ((flag !== 0) << 5); } /** @@ -306,7 +306,7 @@ } out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); + bias = adapt(i - oldi, out, oldi === 0); // `i` was supposed to wrap around from `out` to `0`, // incrementing `n` each time, so we'll fix that now: @@ -410,7 +410,7 @@ error('overflow'); } - if (currentValue == n) { + if (currentValue === n) { // Represent delta as a generalized variable-length integer for (q = delta, k = base; /* no condition */; k += base) { t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); @@ -426,7 +426,7 @@ } output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength); delta = 0; ++handledCPCount; } @@ -508,15 +508,15 @@ // Some AMD build optimizers, like r.js, check for specific condition patterns // like the following: if ( - typeof define == 'function' && - typeof define.amd == 'object' && + typeof define === 'function' && + typeof define.amd === 'object' && define.amd ) { define('punycode', function() { return punycode; }); } else if (freeExports && freeModule) { - if (module.exports == freeExports) { // in Node.js or RingoJS v0.8.0+ + if (module.exports === freeExports) { // in Node.js or RingoJS v0.8.0+ freeModule.exports = punycode; } else { // in Narwhal or RingoJS v0.7.0- for (key in punycode) { diff --git a/lib/readline.js b/lib/readline.js index 02fa9d08f666f9..2083c10e22ad67 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -419,7 +419,7 @@ Interface.prototype._tabComplete = function() { // this = Interface instance function handleGroup(self, group, width, maxColumns) { - if (group.length == 0) { + if (group.length === 0) { return; } var minRows = Math.ceil(group.length / maxColumns); @@ -444,14 +444,14 @@ function handleGroup(self, group, width, maxColumns) { } function commonPrefix(strings) { - if (!strings || strings.length == 0) { + if (!strings || strings.length === 0) { return ''; } var sorted = strings.slice().sort(); var min = sorted[0]; var max = sorted[sorted.length - 1]; for (var i = 0, len = min.length; i < len; i++) { - if (min[i] != max[i]) { + if (min[i] !== max[i]) { return min.slice(0, i); } } @@ -664,7 +664,7 @@ Interface.prototype._ttyWrite = function(s, key) { key = key || {}; // Ignore escape key - Fixes #2876 - if (key.name == 'escape') return; + if (key.name === 'escape') return; if (key.ctrl && key.shift) { /* Control and shift pressed */ @@ -745,7 +745,7 @@ Interface.prototype._ttyWrite = function(s, key) { break; case 'z': - if (process.platform == 'win32') break; + if (process.platform === 'win32') break; if (EventEmitter.listenerCount(this, 'SIGTSTP') > 0) { this.emit('SIGTSTP'); } else { @@ -930,7 +930,7 @@ function emitKeypressEvents(stream) { } function onNewListener(event) { - if (event == 'keypress') { + if (event === 'keypress') { stream.on('data', onData); stream.removeListener('newListener', onNewListener); } diff --git a/lib/repl.js b/lib/repl.js index 366b2b7b0a7c60..245b5962e1b9d1 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -730,7 +730,7 @@ REPLServer.prototype.complete = function(line, callback) { this.eval(expr, this.context, 'repl', function(e, obj) { // if (e) console.log(e); - if (obj != null) { + if (obj !== null && obj !== undefined) { if (typeof obj === 'object' || typeof obj === 'function') { try { memberGroups.push(Object.getOwnPropertyNames(obj)); @@ -795,7 +795,7 @@ REPLServer.prototype.complete = function(line, callback) { var newCompletionGroups = []; for (i = 0; i < completionGroups.length; i++) { group = completionGroups[i].filter(function(elem) { - return elem.indexOf(filter) == 0; + return elem.indexOf(filter) === 0; }); if (group.length) { newCompletionGroups.push(group); diff --git a/lib/timers.js b/lib/timers.js index 494c599b3cdfa1..9920e6bae84105 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -559,7 +559,7 @@ exports._unrefActive = function(item) { var cur, them; - for (cur = unrefList._idlePrev; cur != unrefList; cur = cur._idlePrev) { + for (cur = unrefList._idlePrev; cur !== unrefList; cur = cur._idlePrev) { them = cur._idleStart + cur._idleTimeout; if (when < them) { diff --git a/lib/zlib.js b/lib/zlib.js index a10d9118d6194e..d7744c9dc8b715 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -335,11 +335,11 @@ function Zlib(opts, mode) { } if (opts.strategy) { - if (opts.strategy != exports.Z_FILTERED && - opts.strategy != exports.Z_HUFFMAN_ONLY && - opts.strategy != exports.Z_RLE && - opts.strategy != exports.Z_FIXED && - opts.strategy != exports.Z_DEFAULT_STRATEGY) { + if (opts.strategy !== exports.Z_FILTERED && + opts.strategy !== exports.Z_HUFFMAN_ONLY && + opts.strategy !== exports.Z_RLE && + opts.strategy !== exports.Z_FIXED && + opts.strategy !== exports.Z_DEFAULT_STRATEGY) { throw new Error('Invalid strategy: ' + opts.strategy); } } @@ -394,11 +394,11 @@ Zlib.prototype.params = function(level, strategy, callback) { level > exports.Z_MAX_LEVEL) { throw new RangeError('Invalid compression level: ' + level); } - if (strategy != exports.Z_FILTERED && - strategy != exports.Z_HUFFMAN_ONLY && - strategy != exports.Z_RLE && - strategy != exports.Z_FIXED && - strategy != exports.Z_DEFAULT_STRATEGY) { + if (strategy !== exports.Z_FILTERED && + strategy !== exports.Z_HUFFMAN_ONLY && + strategy !== exports.Z_RLE && + strategy !== exports.Z_FIXED && + strategy !== exports.Z_DEFAULT_STRATEGY) { throw new TypeError('Invalid strategy: ' + strategy); } diff --git a/src/node.js b/src/node.js index af66b1784e7181..d1deb144fca9ce 100644 --- a/src/node.js +++ b/src/node.js @@ -58,12 +58,12 @@ NativeModule.require('_third_party_main'); }); - } else if (process.argv[1] == 'debug') { + } else if (process.argv[1] === 'debug') { // Start the debugger agent var d = NativeModule.require('_debugger'); d.start(); - } else if (process.argv[1] == '--debug-agent') { + } else if (process.argv[1] === '--debug-agent') { // Start the debugger agent var d = NativeModule.require('_debug_agent'); d.start(); @@ -82,7 +82,7 @@ delete process.env.NODE_UNIQUE_ID; } - if (process._eval != null) { + if (process._eval !== null && process._eval !== undefined) { // User passed '-e' or '--eval' arguments to Node. startup.preloadModules(); evalScript('[eval]'); @@ -742,7 +742,7 @@ process.kill = function(pid, sig) { var err; - if (pid != (pid | 0)) { + if (pid != (pid | 0)) { // != is used as pid could be a string as well throw new TypeError('invalid pid'); } @@ -870,7 +870,7 @@ NativeModule._cache = {}; NativeModule.require = function(id) { - if (id == 'native_module') { + if (id === 'native_module') { return NativeModule; } diff --git a/test/common.js b/test/common.js index 1ad66cff0b4857..8520fcc6b64e41 100644 --- a/test/common.js +++ b/test/common.js @@ -390,7 +390,7 @@ if (exports.isWindows) { * platforms) can't be read. */ exports.getServiceName = function getServiceName(port, protocol) { - if (port == null) { + if (port === null || port === undefined) { throw new Error('Missing port number'); } diff --git a/test/debugger/helper-debugger-repl.js b/test/debugger/helper-debugger-repl.js index 714a22c2a22fdc..8547c8f7b6aa07 100644 --- a/test/debugger/helper-debugger-repl.js +++ b/test/debugger/helper-debugger-repl.js @@ -35,7 +35,7 @@ function startDebugger(scriptToDebug) { assert.ok(expected.length > 0, 'Got unexpected line: ' + line); var expectedLine = expected[0].lines.shift(); - assert.ok(line.match(expectedLine) !== null, line + ' != ' + expectedLine); + assert.ok(line.match(expectedLine) !== null, line + ' !== ' + expectedLine); if (expected[0].lines.length === 0) { var callback = expected[0].callback; diff --git a/test/debugger/test-debug-break-on-uncaught.js b/test/debugger/test-debug-break-on-uncaught.js index 397c4225d27f7e..28311ad8c288ad 100644 --- a/test/debugger/test-debug-break-on-uncaught.js +++ b/test/debugger/test-debug-break-on-uncaught.js @@ -96,7 +96,7 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) { assert.equal(exceptions.length, 1, 'debugger did not pause on exception'); assert.equal(exceptions[0].uncaught, true); assert.equal(exceptions[0].script.name, throwsInFile || testScript); - if (throwsOnLine != null) + if (throwsOnLine !== null && throwsOnLine !== undefined) assert.equal(exceptions[0].sourceLine + 1, throwsOnLine); asserted = true; client.reqContinue(assert.ifError); diff --git a/test/debugger/test-debugger-pid.js b/test/debugger/test-debugger-pid.js index 14a281ab3ce4cc..eff36abf1043de 100644 --- a/test/debugger/test-debugger-pid.js +++ b/test/debugger/test-debugger-pid.js @@ -31,9 +31,9 @@ interfacer.stderr.on('data', onData); interfacer.on('line', function(line) { line = line.replace(/^(debug> *)+/, ''); var expected = 'Target process: 655555 doesn\'t exist.'; - assert.ok(expected == line, 'Got unexpected line: ' + line); + assert.ok(expected === line, 'Got unexpected line: ' + line); }); interfacer.on('exit', function(code, signal) { - assert.ok(code == 1, 'Got unexpected code: ' + code); + assert.ok(code === 1, 'Got unexpected code: ' + code); }); diff --git a/test/debugger/test-debugger-remote.js b/test/debugger/test-debugger-remote.js index 81ed8b41ab0198..e1d1d610eb6586 100644 --- a/test/debugger/test-debugger-remote.js +++ b/test/debugger/test-debugger-remote.js @@ -34,7 +34,7 @@ interfacer.on('line', function(line) { line = line.replace(/^(debug> *)+/, ''); console.log(line); var expected = '\bconnecting to localhost:5959 ... ok'; - assert.ok(expected == line, 'Got unexpected line: ' + line); + assert.ok(expected === line, 'Got unexpected line: ' + line); }); // allow time to start up the debugger diff --git a/test/disabled/test-child-process-uid-gid.js b/test/disabled/test-child-process-uid-gid.js index 90708bc2ca4016..5879faa720b2d6 100644 --- a/test/disabled/test-child-process-uid-gid.js +++ b/test/disabled/test-child-process-uid-gid.js @@ -7,7 +7,7 @@ var fs = require('fs'); var myUid = process.getuid(); var myGid = process.getgid(); -if (myUid != 0) { +if (myUid !== 0) { console.error('must be run as root, otherwise the gid/uid setting will' + ' fail.'); process.exit(1); diff --git a/test/disabled/test-sendfd.js b/test/disabled/test-sendfd.js index 4eefbeab549685..363dc22192d898 100644 --- a/test/disabled/test-sendfd.js +++ b/test/disabled/test-sendfd.js @@ -46,7 +46,7 @@ var SOCK_PATH = path.join(__dirname, path.basename(__filename, '.js') + '.sock'); var logChild = function(d) { - if (typeof d == 'object') { + if (typeof d === 'object') { d = d.toString(); } diff --git a/test/fixtures/breakpoints.js b/test/fixtures/breakpoints.js index 4824767ff0051d..4b02648e765d83 100644 --- a/test/fixtures/breakpoints.js +++ b/test/fixtures/breakpoints.js @@ -1,7 +1,7 @@ debugger; function a(x) { var i = 10; - while (--i != 0); + while (--i !== 0); debugger; return i; } diff --git a/test/fixtures/breakpoints_utf8.js b/test/fixtures/breakpoints_utf8.js index 8f0eb9dfc117e6..1571e3536fdf42 100644 --- a/test/fixtures/breakpoints_utf8.js +++ b/test/fixtures/breakpoints_utf8.js @@ -1,7 +1,7 @@ debugger; function a(x) { var i = 10; - while (--i != 0); + while (--i !== 0); debugger; return i; } diff --git a/test/fixtures/not-main-module.js b/test/fixtures/not-main-module.js index 3da57f44285910..a5da6744177bd4 100644 --- a/test/fixtures/not-main-module.js +++ b/test/fixtures/not-main-module.js @@ -1,4 +1,4 @@ var assert = require('assert'); -assert.notEqual(module, require.main, 'require.main should not == module'); +assert.notEqual(module, require.main, 'require.main should not === module'); assert.notEqual(module, process.mainModule, 'process.mainModule should not === module'); diff --git a/test/fixtures/recvfd.js b/test/fixtures/recvfd.js index 75df69a3dc3954..9a5fd4c5408ac2 100644 --- a/test/fixtures/recvfd.js +++ b/test/fixtures/recvfd.js @@ -8,7 +8,7 @@ var receivedFDs = []; var numSentMessages = 0; function processData(s) { - if (receivedData.length == 0 || receivedFDs.length == 0) { + if (receivedData.length === 0 || receivedFDs.length === 0) { return; } @@ -25,7 +25,7 @@ function processData(s) { var drainFunc = function() { pipeStream.destroy(); - if (++numSentMessages == 2) { + if (++numSentMessages === 2) { s.destroy(); } }; diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js index 4cf5d7226f2c50..05575834d841be 100644 --- a/test/internet/test-dgram-broadcast-multi-process.js +++ b/test/internet/test-dgram-broadcast-multi-process.js @@ -61,7 +61,7 @@ if (process.argv[2] !== 'child') { // don't consider this the true death if the worker // has finished successfully // or if the exit code is 0 - if (worker.isDone || code == 0) { + if (worker.isDone || code === 0) { return; } @@ -200,7 +200,7 @@ if (process.argv[2] === 'child') { process.send({ message: buf.toString() }); - if (receivedMessages.length == messages.length) { + if (receivedMessages.length === messages.length) { process.nextTick(function() { listenSocket.close(); }); diff --git a/test/internet/test-dgram-multicast-multi-process.js b/test/internet/test-dgram-multicast-multi-process.js index 34db38331dc7b6..ac295786e26bbd 100644 --- a/test/internet/test-dgram-multicast-multi-process.js +++ b/test/internet/test-dgram-multicast-multi-process.js @@ -181,7 +181,7 @@ if (process.argv[2] === 'child') { process.send({ message: buf.toString() }); - if (receivedMessages.length == messages.length) { + if (receivedMessages.length === messages.length) { // .dropMembership() not strictly needed but here as a sanity check listenSocket.dropMembership(LOCAL_BROADCAST_HOST); process.nextTick(function() { diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index eb7bab85475b2a..14d44abdcbe1f7 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -709,7 +709,7 @@ req.oncomplete = function(err, domains) { console.log('nodejs.org = ', domains); assert.ok(Array.isArray(domains)); assert.ok(domains.length >= 1); - assert.ok(typeof domains[0] == 'string'); + assert.ok(typeof domains[0] === 'string'); getaddrinfoCallbackCalled = true; }; diff --git a/test/parallel/test-child-process-exec-cwd.js b/test/parallel/test-child-process-exec-cwd.js index e253399b96ac30..72e990ea2f1d04 100644 --- a/test/parallel/test-child-process-exec-cwd.js +++ b/test/parallel/test-child-process-exec-cwd.js @@ -26,7 +26,7 @@ var child = exec(pwdcommand, {cwd: dir}, function(err, stdout, stderr) { } else { success_count++; console.log(stdout); - assert.ok(stdout.indexOf(dir) == 0); + assert.ok(stdout.indexOf(dir) === 0); } }); diff --git a/test/parallel/test-child-process-exec-env.js b/test/parallel/test-child-process-exec-env.js index e80531e87e9ee5..e358dd828d09d8 100644 --- a/test/parallel/test-child-process-exec-env.js +++ b/test/parallel/test-child-process-exec-env.js @@ -16,7 +16,7 @@ function after(err, stdout, stderr) { assert.equal(false, err.killed); } else { success_count++; - assert.equal(true, stdout != ''); + assert.equal(true, stdout !== ''); } } diff --git a/test/parallel/test-child-process-fork.js b/test/parallel/test-child-process-fork.js index c35510e60c76f4..a53cca249c3b21 100644 --- a/test/parallel/test-child-process-fork.js +++ b/test/parallel/test-child-process-fork.js @@ -28,5 +28,5 @@ n.on('exit', function(c) { }); process.on('exit', function() { - assert.ok(childExitCode == 0); + assert.ok(childExitCode === 0); }); diff --git a/test/parallel/test-cluster-dgram-1.js b/test/parallel/test-cluster-dgram-1.js index 9404c55f2bb547..f05478099619d1 100644 --- a/test/parallel/test-cluster-dgram-1.js +++ b/test/parallel/test-cluster-dgram-1.js @@ -86,7 +86,7 @@ function worker() { received++; // Every 10 messages, notify the master. - if (received == PACKETS_PER_WORKER) { + if (received === PACKETS_PER_WORKER) { process.send({received: received}); process.disconnect(); } diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js index 0253cafcf49766..374984dc058049 100644 --- a/test/parallel/test-cluster-dgram-2.js +++ b/test/parallel/test-cluster-dgram-2.js @@ -33,7 +33,7 @@ function master() { socket.on('message', function(data, info) { received++; - if (received == PACKETS_PER_WORKER * NUM_WORKERS) { + if (received === PACKETS_PER_WORKER * NUM_WORKERS) { console.log('master received %d packets', received); // Close the socket. diff --git a/test/parallel/test-cluster-uncaught-exception.js b/test/parallel/test-cluster-uncaught-exception.js index ec42773ef55856..75043e13a8e9fe 100644 --- a/test/parallel/test-cluster-uncaught-exception.js +++ b/test/parallel/test-cluster-uncaught-exception.js @@ -10,7 +10,7 @@ var fork = require('child_process').fork; var MAGIC_EXIT_CODE = 42; -var isTestRunner = process.argv[2] != 'child'; +var isTestRunner = process.argv[2] !== 'child'; if (isTestRunner) { var exitCode = -1; diff --git a/test/parallel/test-cluster-worker-exit.js b/test/parallel/test-cluster-worker-exit.js index 3607a992a33dff..a0e2cce993ca66 100644 --- a/test/parallel/test-cluster-worker-exit.js +++ b/test/parallel/test-cluster-worker-exit.js @@ -88,7 +88,7 @@ if (cluster.isWorker) { checkResults(expected_results, results); } catch (exc) { console.error('FAIL: ' + exc.message); - if (exc.name != 'AssertionError') { + if (exc.name !== 'AssertionError') { console.trace(exc); } diff --git a/test/parallel/test-cluster-worker-kill.js b/test/parallel/test-cluster-worker-kill.js index e12b466610171a..64534caa57abf0 100644 --- a/test/parallel/test-cluster-worker-kill.js +++ b/test/parallel/test-cluster-worker-kill.js @@ -88,7 +88,7 @@ if (cluster.isWorker) { checkResults(expected_results, results); } catch (exc) { console.error('FAIL: ' + exc.message); - if (exc.name != 'AssertionError') { + if (exc.name !== 'AssertionError') { console.trace(exc); } diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js index 2cc36278332c9b..2f481afc8966fd 100644 --- a/test/parallel/test-crypto-authenticated.js +++ b/test/parallel/test-crypto-authenticated.js @@ -55,7 +55,7 @@ var ciphers = crypto.getCiphers(); for (var i in TEST_CASES) { var test = TEST_CASES[i]; - if (ciphers.indexOf(test.algo) == -1) { + if (ciphers.indexOf(test.algo) === -1) { console.log('1..0 # Skipped: unsupported ' + test.algo + ' test'); continue; } diff --git a/test/parallel/test-dgram-empty-packet.js b/test/parallel/test-dgram-empty-packet.js index ba6faa62d86cec..021dc1054ba2e7 100644 --- a/test/parallel/test-dgram-empty-packet.js +++ b/test/parallel/test-dgram-empty-packet.js @@ -19,7 +19,7 @@ client.bind(common.PORT); function callback() { callbacks++; - if (callbacks == 2) { + if (callbacks === 2) { clearTimeout(timer); client.close(); } else if (callbacks > 2) { diff --git a/test/parallel/test-file-write-stream.js b/test/parallel/test-file-write-stream.js index 7309a6bf9db4d3..0c956f63783c4d 100644 --- a/test/parallel/test-file-write-stream.js +++ b/test/parallel/test-file-write-stream.js @@ -31,10 +31,10 @@ file .on('drain', function() { console.error('drain!', callbacks.drain); callbacks.drain++; - if (callbacks.drain == -1) { + if (callbacks.drain === -1) { assert.equal(EXPECTED, fs.readFileSync(fn, 'utf8')); file.write(EXPECTED); - } else if (callbacks.drain == 0) { + } else if (callbacks.drain === 0) { assert.equal(EXPECTED + EXPECTED, fs.readFileSync(fn, 'utf8')); file.end(); } diff --git a/test/parallel/test-file-write-stream2.js b/test/parallel/test-file-write-stream2.js index 0044548b736df0..078da0c2d93a3d 100644 --- a/test/parallel/test-file-write-stream2.js +++ b/test/parallel/test-file-write-stream2.js @@ -61,7 +61,7 @@ file.on('drain', function() { assert.equal(fs.readFileSync(filepath, 'utf8'), EXPECTED); console.error('ondrain write ret=%j', file.write(EXPECTED)); cb_occurred += 'write '; - } else if (countDrains == 2) { + } else if (countDrains === 2) { console.error('second drain, end'); assert.equal(fs.readFileSync(filepath, 'utf8'), EXPECTED + EXPECTED); file.end(); @@ -86,6 +86,6 @@ for (var i = 0; i < 11; i++) { console.error('%d %j', i, ret); // return false when i hits 10 - assert(ret === (i != 10)); + assert(ret === (i !== 10)); } cb_occurred += 'write '; diff --git a/test/parallel/test-fs-readfile-unlink.js b/test/parallel/test-fs-readfile-unlink.js index 15491b71c433ed..a64c7e7316a94a 100644 --- a/test/parallel/test-fs-readfile-unlink.js +++ b/test/parallel/test-fs-readfile-unlink.js @@ -13,14 +13,14 @@ try { fs.mkdirSync(dirName); } catch (e) { // Ignore if the directory already exists. - if (e.code != 'EEXIST') throw e; + if (e.code !== 'EEXIST') throw e; } fs.writeFileSync(fileName, buf); fs.readFile(fileName, function(err, data) { assert.ifError(err); - assert(data.length == buf.length); + assert(data.length === buf.length); assert.strictEqual(buf[0], 42); fs.unlinkSync(fileName); diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 9082e1d65f4d0e..63b8c73c4614e9 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -18,7 +18,7 @@ if (common.isWindows) { // We'll only try to run symlink test if we have enough privileges. try { exec('whoami /priv', function(err, o) { - if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) { + if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') === -1) { skipSymlinks = true; } runTest(); diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js index 199add4a1ba724..e6c9c8ccf0c3ef 100644 --- a/test/parallel/test-fs-symlink.js +++ b/test/parallel/test-fs-symlink.js @@ -59,7 +59,7 @@ if (common.isWindows) { // On Windows, creating symlinks requires admin privileges. // We'll only try to run symlink test if we have enough privileges. exec('whoami /priv', function(err, o) { - if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) { + if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') === -1) { expected_async = 1; runtest(true); } else { diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index 292636b1b69108..781abad91da19a 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -8,7 +8,7 @@ var tests_ok = 0; var tests_run = 0; function stat_resource(resource) { - if (typeof resource == 'string') { + if (typeof resource === 'string') { return fs.statSync(resource); } else { // ensure mtime has been written to disk @@ -23,7 +23,7 @@ function check_mtime(resource, mtime) { var real_mtime = fs._toUnixTimestamp(stats.mtime); // check up to single-second precision // sub-second precision is OS and fs dependant - return Math.floor(mtime) == Math.floor(real_mtime); + return Math.floor(mtime) === Math.floor(real_mtime); } function expect_errno(syscall, resource, err, errno) { diff --git a/test/parallel/test-http-agent.js b/test/parallel/test-http-agent.js index 09ba9c34e2936d..d70efb2bb224a4 100644 --- a/test/parallel/test-http-agent.js +++ b/test/parallel/test-http-agent.js @@ -18,7 +18,7 @@ server.listen(common.PORT, function() { for (var j = 0; j < M; j++) { http.get({ port: common.PORT, path: '/' }, function(res) { console.log('%d %d', responses, res.statusCode); - if (++responses == N * M) { + if (++responses === N * M) { console.error('Received all responses, closing server'); server.close(); } diff --git a/test/parallel/test-http-allow-req-after-204-res.js b/test/parallel/test-http-allow-req-after-204-res.js index ba98138bdca568..6efc420d321cbd 100644 --- a/test/parallel/test-http-allow-req-after-204-res.js +++ b/test/parallel/test-http-allow-req-after-204-res.js @@ -28,7 +28,7 @@ function nextRequest() { path: '/' }, function(response) { response.on('end', function() { - if (methods.length == 0) { + if (methods.length === 0) { console.error('close server'); server.close(); } else { diff --git a/test/parallel/test-http-client-abort.js b/test/parallel/test-http-client-abort.js index c3353bb72201b6..8ca672400dc5e8 100644 --- a/test/parallel/test-http-client-abort.js +++ b/test/parallel/test-http-client-abort.js @@ -43,7 +43,7 @@ server.listen(common.PORT, function() { console.log('Client response code ' + res.statusCode); res.resume(); - if (++responses == N) { + if (++responses === N) { console.log('All clients connected, destroying.'); requests.forEach(function(outReq) { console.log('abort'); diff --git a/test/parallel/test-http-client-timeout-agent.js b/test/parallel/test-http-client-timeout-agent.js index 809742f5628df5..0487e14e1659d5 100644 --- a/test/parallel/test-http-client-timeout-agent.js +++ b/test/parallel/test-http-client-timeout-agent.js @@ -72,6 +72,6 @@ server.listen(options.port, options.host, function() { process.on('exit', function() { console.error('done=%j sent=%j', requests_done, requests_sent); - assert.ok(requests_done == requests_sent, + assert.ok(requests_done === requests_sent, 'timeout on http request called too much'); }); diff --git a/test/parallel/test-http-exceptions.js b/test/parallel/test-http-exceptions.js index dc2d5583ddbaf9..14ad97503bc852 100644 --- a/test/parallel/test-http-exceptions.js +++ b/test/parallel/test-http-exceptions.js @@ -22,6 +22,6 @@ var exception_count = 0; process.on('uncaughtException', function(err) { console.log('Caught an exception: ' + err); if (err.name === 'AssertionError') throw err; - if (++exception_count == 4) process.exit(0); + if (++exception_count === 4) process.exit(0); }); diff --git a/test/parallel/test-http-expect-continue.js b/test/parallel/test-http-expect-continue.js index 1a1418a41c421f..001b8857c423c9 100644 --- a/test/parallel/test-http-expect-continue.js +++ b/test/parallel/test-http-expect-continue.js @@ -58,7 +58,7 @@ server.on('listening', function() { assert.equal(body, test_res_body, 'Response body doesn\'t match.'); assert.ok('abcd' in res.headers, 'Response headers missing.'); outstanding_reqs--; - if (outstanding_reqs == 0) { + if (outstanding_reqs === 0) { server.close(); process.exit(); } diff --git a/test/parallel/test-http-get-pipeline-problem.js b/test/parallel/test-http-get-pipeline-problem.js index 4f0d52aad5195d..c412453d870e00 100644 --- a/test/parallel/test-http-get-pipeline-problem.js +++ b/test/parallel/test-http-get-pipeline-problem.js @@ -17,7 +17,7 @@ var total = 100; var requests = 0, responses = 0; var server = http.Server(function(req, res) { - if (++requests == total) { + if (++requests === total) { server.close(); } @@ -49,7 +49,7 @@ server.listen(common.PORT, function() { s.on('finish', function() { console.error('done ' + x); - if (++responses == total) { + if (++responses === total) { checkFiles(); } }); diff --git a/test/parallel/test-http-incoming-pipelined-socket-destroy.js b/test/parallel/test-http-incoming-pipelined-socket-destroy.js index 21cd3e69dfd746..22518ecae35a04 100644 --- a/test/parallel/test-http-incoming-pipelined-socket-destroy.js +++ b/test/parallel/test-http-incoming-pipelined-socket-destroy.js @@ -53,7 +53,7 @@ server.listen(common.PORT, function() { var client = net.connect({ port: common.PORT }); var done = 0; server.on('requestDone', function() { - if (++done == seeds.length) { + if (++done === seeds.length) { server.close(); } }); diff --git a/test/parallel/test-http-legacy.js b/test/parallel/test-http-legacy.js index 039037114d37d4..f614514f4054b5 100644 --- a/test/parallel/test-http-legacy.js +++ b/test/parallel/test-http-legacy.js @@ -14,7 +14,7 @@ var body0 = ''; var body1 = ''; var server = http.createServer(function(req, res) { - if (responses_sent == 0) { + if (responses_sent === 0) { assert.equal('GET', req.method); assert.equal('/hello', url.parse(req.url).pathname); @@ -26,7 +26,7 @@ var server = http.createServer(function(req, res) { assert.equal('bar', req.headers['foo']); } - if (responses_sent == 1) { + if (responses_sent === 1) { assert.equal('POST', req.method); assert.equal('/world', url.parse(req.url).pathname); this.close(); diff --git a/test/parallel/test-http-malformed-request.js b/test/parallel/test-http-malformed-request.js index c83aeca9b943fa..9b4827b682b500 100644 --- a/test/parallel/test-http-malformed-request.js +++ b/test/parallel/test-http-malformed-request.js @@ -18,7 +18,7 @@ var server = http.createServer(function(req, res) { res.write('Hello World'); res.end(); - if (++nrequests_completed == nrequests_expected) server.close(); + if (++nrequests_completed === nrequests_expected) server.close(); }); server.listen(common.PORT); diff --git a/test/parallel/test-http-many-ended-pipelines.js b/test/parallel/test-http-many-ended-pipelines.js index 4e0bc7e8ff736f..4782ac07755f7e 100644 --- a/test/parallel/test-http-many-ended-pipelines.js +++ b/test/parallel/test-http-many-ended-pipelines.js @@ -20,7 +20,7 @@ var server = http.createServer(function(req, res) { // Oh no! The connection died! req.socket.destroy(); - if (++done == numRequests) + if (++done === numRequests) server.close(); }); diff --git a/test/parallel/test-http-server.js b/test/parallel/test-http-server.js index 9ba13ddf96b6ec..9ea59ec74f181a 100644 --- a/test/parallel/test-http-server.js +++ b/test/parallel/test-http-server.js @@ -15,25 +15,25 @@ var server = http.createServer(function(req, res) { res.id = request_number; req.id = request_number++; - if (req.id == 0) { + if (req.id === 0) { assert.equal('GET', req.method); assert.equal('/hello', url.parse(req.url).pathname); assert.equal('world', qs.parse(url.parse(req.url).query).hello); assert.equal('b==ar', qs.parse(url.parse(req.url).query).foo); } - if (req.id == 1) { + if (req.id === 1) { common.error('req 1'); assert.equal('POST', req.method); assert.equal('/quit', url.parse(req.url).pathname); } - if (req.id == 2) { + if (req.id === 2) { common.error('req 2'); assert.equal('foo', req.headers['x-x']); } - if (req.id == 3) { + if (req.id === 3) { common.error('req 3'); assert.equal('bar', req.headers['x-x']); this.close(); @@ -64,12 +64,12 @@ server.on('listening', function() { c.on('data', function(chunk) { server_response += chunk; - if (requests_sent == 1) { + if (requests_sent === 1) { c.write('POST /quit HTTP/1.1\r\n\r\n'); requests_sent += 1; } - if (requests_sent == 2) { + if (requests_sent === 2) { c.write('GET / HTTP/1.1\r\nX-X: foo\r\n\r\n' + 'GET / HTTP/1.1\r\nX-X: bar\r\n\r\n'); // Note: we are making the connection half-closed here @@ -99,10 +99,12 @@ process.on('exit', function() { assert.equal(4, requests_sent); var hello = new RegExp('/hello'); - assert.equal(true, hello.exec(server_response) != null); + var res = hello.exec(server_response); + assert.equal(true, res !== null && res !== undefined); var quit = new RegExp('/quit'); - assert.equal(true, quit.exec(server_response) != null); + res = quit.exec(server_response); + assert.equal(true, res !== null && res !== undefined); assert.equal(true, client_got_eof); }); diff --git a/test/parallel/test-http-set-cookies.js b/test/parallel/test-http-set-cookies.js index 9a43f82a39c12e..cba874d0e0e451 100644 --- a/test/parallel/test-http-set-cookies.js +++ b/test/parallel/test-http-set-cookies.js @@ -6,7 +6,7 @@ var http = require('http'); var nresponses = 0; var server = http.createServer(function(req, res) { - if (req.url == '/one') { + if (req.url === '/one') { res.writeHead(200, [['set-cookie', 'A'], ['content-type', 'text/plain']]); res.end('one\n'); @@ -34,7 +34,7 @@ server.on('listening', function() { }); res.on('end', function() { - if (++nresponses == 2) { + if (++nresponses === 2) { server.close(); } }); @@ -51,7 +51,7 @@ server.on('listening', function() { }); res.on('end', function() { - if (++nresponses == 2) { + if (++nresponses === 2) { server.close(); } }); diff --git a/test/parallel/test-http-set-trailers.js b/test/parallel/test-http-set-trailers.js index 6f5c02f5605969..c6763615bac534 100644 --- a/test/parallel/test-http-set-trailers.js +++ b/test/parallel/test-http-set-trailers.js @@ -35,7 +35,7 @@ server.on('listening', function() { c.end(); assert.ok(! /x-foo/.test(res_buffer), 'Trailer in HTTP/1.0 response.'); outstanding_reqs--; - if (outstanding_reqs == 0) { + if (outstanding_reqs === 0) { server.close(); process.exit(); } @@ -66,7 +66,7 @@ server.on('listening', function() { /0\r\nx-foo: bar\r\n\r\n$/.test(res_buffer), 'No trailer in HTTP/1.1 response.' ); - if (outstanding_reqs == 0) { + if (outstanding_reqs === 0) { server.close(); process.exit(); } @@ -81,7 +81,7 @@ server.on('listening', function() { //console.log(res.trailers); assert.ok('x-foo' in res.trailers, 'Client doesn\'t see trailers.'); outstanding_reqs--; - if (outstanding_reqs == 0) { + if (outstanding_reqs === 0) { server.close(); process.exit(); } diff --git a/test/parallel/test-http-timeout.js b/test/parallel/test-http-timeout.js index aab903420f0acc..4b516df4ccb616 100644 --- a/test/parallel/test-http-timeout.js +++ b/test/parallel/test-http-timeout.js @@ -31,7 +31,7 @@ server.listen(port, function() { res.on('end', function() { count++; - if (count == 11) { + if (count === 11) { server.close(); } }); diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js index 9b34fe42eb05b9..86f3fa721a852f 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -39,7 +39,7 @@ function testServer() { socket.on('data', function(d) { var data = d.toString('utf8'); - if (data == 'kill') { + if (data === 'kill') { socket.end(); } else { socket.write(data, 'utf8'); @@ -79,11 +79,11 @@ function test_upgrade_with_listener(_server) { assert.equal('string', typeof data); - if (state == 1) { + if (state === 1) { assert.equal('HTTP/1.1 101', data.substr(0, 12)); assert.equal('WjN}|M(6', request_upgradeHead.toString('utf8')); conn.write('test', 'utf8'); - } else if (state == 2) { + } else if (state === 2) { assert.equal('test', data); conn.write('kill', 'utf8'); } diff --git a/test/parallel/test-http.js b/test/parallel/test-http.js index daa746cdbe5b7a..5d2ee062a37980 100644 --- a/test/parallel/test-http.js +++ b/test/parallel/test-http.js @@ -14,7 +14,7 @@ var body0 = ''; var body1 = ''; var server = http.Server(function(req, res) { - if (responses_sent == 0) { + if (responses_sent === 0) { assert.equal('GET', req.method); assert.equal('/hello', url.parse(req.url).pathname); @@ -26,7 +26,7 @@ var server = http.Server(function(req, res) { assert.equal('bar', req.headers['foo']); } - if (responses_sent == 1) { + if (responses_sent === 1) { assert.equal('POST', req.method); assert.equal('/world', url.parse(req.url).pathname); this.close(); diff --git a/test/parallel/test-https-agent.js b/test/parallel/test-https-agent.js index a3bb28975a3155..3ec4efcccea757 100644 --- a/test/parallel/test-https-agent.js +++ b/test/parallel/test-https-agent.js @@ -37,7 +37,7 @@ server.listen(common.PORT, function() { }, function(res) { res.resume(); console.log(res.statusCode); - if (++responses == N * M) server.close(); + if (++responses === N * M) server.close(); }).on('error', function(e) { console.log(e.message); process.exit(1); diff --git a/test/parallel/test-intl.js b/test/parallel/test-intl.js index 7288febf9e6bfd..5d4f7ad3759aaf 100644 --- a/test/parallel/test-intl.js +++ b/test/parallel/test-intl.js @@ -9,7 +9,7 @@ if (enablei18n === undefined) { } // is the Intl object present? -var haveIntl = (global.Intl != undefined); +var haveIntl = (global.Intl !== undefined); // Returns true if no specific locale ids were configured (i.e. "all") // Else, returns true if loc is in the configured list diff --git a/test/parallel/test-net-binary.js b/test/parallel/test-net-binary.js index cf29cfe63bad71..3fb32ad17d2749 100644 --- a/test/parallel/test-net-binary.js +++ b/test/parallel/test-net-binary.js @@ -14,8 +14,8 @@ for (var i = 255; i >= 0; i--) { JSON.stringify(String.fromCharCode(i)) + ' ' + S.charCodeAt(0)); - assert.ok(S.charCodeAt(0) == i); - assert.ok(S == String.fromCharCode(i)); + assert.ok(S.charCodeAt(0) === i); + assert.ok(S === String.fromCharCode(i)); binaryString += S; } diff --git a/test/parallel/test-net-pipe-connect-errors.js b/test/parallel/test-net-pipe-connect-errors.js index e2ec1debf12617..9f6c7668c5a6fd 100644 --- a/test/parallel/test-net-pipe-connect-errors.js +++ b/test/parallel/test-net-pipe-connect-errors.js @@ -27,7 +27,7 @@ if (common.isWindows) { try { fs.unlinkSync(emptyTxt); } catch (e) { - if (e.code != 'ENOENT') + if (e.code !== 'ENOENT') throw e; } } diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index 11d753ea460b79..4dc6bcd775b41c 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -19,7 +19,7 @@ var server = net.createServer(function(socket) { assert.ok(socket.remotePort); assert.notEqual(socket.remotePort, common.PORT); socket.on('end', function() { - if (++conns_closed == 2) server.close(); + if (++conns_closed === 2) server.close(); }); socket.on('close', function() { assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress)); diff --git a/test/parallel/test-net-server-try-ports.js b/test/parallel/test-net-server-try-ports.js index 742062abf62690..61b74a8723f038 100644 --- a/test/parallel/test-net-server-try-ports.js +++ b/test/parallel/test-net-server-try-ports.js @@ -26,7 +26,7 @@ server2.on('error', function(e) { server2errors++; console.error('server2 error'); - if (e.code == 'EADDRINUSE') { + if (e.code === 'EADDRINUSE') { server2eaddrinuse = true; } diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index 4c0e31d08c4771..a4a05e964690e4 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -23,7 +23,7 @@ server.on('close', function() { server.listen(common.PORT, common.localhostIPv4, testConnect); function testConnect() { - if (conns == 2) { + if (conns === 2) { return server.close(); } client.connect(common.PORT, common.localhostIPv4, function() { diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index f7fe4634c40dca..bb24c3afe43db3 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -71,7 +71,7 @@ var arch = os.arch(); console.log('arch = ', arch); assert.ok(arch.length > 0); -if (process.platform != 'sunos') { +if (process.platform !== 'sunos') { // not implemeneted yet assert.ok(os.loadavg().length > 0); assert.ok(os.freemem() > 0); @@ -83,7 +83,7 @@ var interfaces = os.networkInterfaces(); console.error(interfaces); switch (platform) { case 'linux': - var filter = function(e) { return e.address == '127.0.0.1'; }; + var filter = function(e) { return e.address === '127.0.0.1'; }; var actual = interfaces.lo.filter(filter); var expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', mac: '00:00:00:00:00:00', family: 'IPv4', @@ -91,7 +91,7 @@ switch (platform) { assert.deepEqual(actual, expected); break; case 'win32': - var filter = function(e) { return e.address == '127.0.0.1'; }; + var filter = function(e) { return e.address === '127.0.0.1'; }; var actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter); var expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', mac: '00:00:00:00:00:00', family: 'IPv4', diff --git a/test/parallel/test-process-env.js b/test/parallel/test-process-env.js index 7e927d09bae668..422e4a7b9b0976 100644 --- a/test/parallel/test-process-env.js +++ b/test/parallel/test-process-env.js @@ -25,7 +25,7 @@ assert.equal(5, date.getHours()); // changes in environment should be visible to child processes -if (process.argv[2] == 'you-are-the-child') { +if (process.argv[2] === 'you-are-the-child') { // failed assertion results in process exiting with status code 1 assert.equal(false, 'NODE_PROCESS_ENV_DELETED' in process.env); assert.equal(42, process.env.NODE_PROCESS_ENV); @@ -54,7 +54,7 @@ if (process.argv[2] == 'you-are-the-child') { child.stdout.on('data', function(data) { console.log(data.toString()); }); child.stderr.on('data', function(data) { console.log(data.toString()); }); child.on('exit', function(statusCode) { - if (statusCode != 0) { + if (statusCode !== 0) { process.exit(statusCode); // failed assertion in child process } }); diff --git a/test/parallel/test-signal-handler.js b/test/parallel/test-signal-handler.js index bcd8256272005b..7ce07fbf9eb137 100644 --- a/test/parallel/test-signal-handler.js +++ b/test/parallel/test-signal-handler.js @@ -32,7 +32,7 @@ var i = 0; setInterval(function() { console.log('running process...' + ++i); - if (i == 5) { + if (i === 5) { process.kill(process.pid, 'SIGUSR1'); } }, 1); diff --git a/test/parallel/test-timers-zero-timeout.js b/test/parallel/test-timers-zero-timeout.js index 1c84814363a641..cfef984e941f8c 100644 --- a/test/parallel/test-timers-zero-timeout.js +++ b/test/parallel/test-timers-zero-timeout.js @@ -30,7 +30,7 @@ var assert = require('assert'); assert.equal(a, 'foo'); assert.equal(b, 'bar'); assert.equal(c, 'baz'); - if (++ncalled == 3) clearTimeout(iv); + if (++ncalled === 3) clearTimeout(iv); } process.on('exit', function() { diff --git a/test/parallel/test-tty-wrap.js b/test/parallel/test-tty-wrap.js index dbe7b6890fd218..4ecbd55d945197 100644 --- a/test/parallel/test-tty-wrap.js +++ b/test/parallel/test-tty-wrap.js @@ -5,7 +5,7 @@ var assert = require('assert'); var TTY = process.binding('tty_wrap').TTY; var isTTY = process.binding('tty_wrap').isTTY; -if (isTTY(1) == false) { +if (isTTY(1) === false) { console.log('1..0 # Skipped: fd 1 is not a tty.'); return; } diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index fcde1c74c3984e..fd30e2da15da42 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -55,9 +55,9 @@ try { assert.equal(util.inspect(e), '[ReferenceError: undef is not defined]'); } var ex = util.inspect(new Error('FAIL'), true); -assert.ok(ex.indexOf('[Error: FAIL]') != -1); -assert.ok(ex.indexOf('[stack]') != -1); -assert.ok(ex.indexOf('[message]') != -1); +assert.ok(ex.indexOf('[Error: FAIL]') !== -1); +assert.ok(ex.indexOf('[stack]') !== -1); +assert.ok(ex.indexOf('[message]') !== -1); // GH-1941 // should not throw: @@ -85,7 +85,7 @@ assert.doesNotThrow(function() { // GH-2225 var x = { inspect: util.inspect }; -assert.ok(util.inspect(x).indexOf('inspect') != -1); +assert.ok(util.inspect(x).indexOf('inspect') !== -1); // util.inspect should not display the escaped value of a key. var w = { diff --git a/test/pummel/test-dtrace-jsstack.js b/test/pummel/test-dtrace-jsstack.js index 67194a3dd77f53..0b2898945b2938 100644 --- a/test/pummel/test-dtrace-jsstack.js +++ b/test/pummel/test-dtrace-jsstack.js @@ -4,7 +4,7 @@ var assert = require('assert'); var os = require('os'); var util = require('util'); -if (os.type() != 'SunOS') { +if (os.type() !== 'SunOS') { console.log('1..0 # Skipped: no DTRACE support'); return; } @@ -56,7 +56,7 @@ dtrace.stdout.on('data', function(data) { }); dtrace.on('exit', function(code) { - if (code != 0) { + if (code !== 0) { console.error('dtrace exited with code ' + code); process.exit(code); } @@ -69,7 +69,7 @@ dtrace.on('exit', function(code) { for (var i = 0; i < lines.length; i++) { var line = lines[i]; - if (line.indexOf(sentinel) == -1 || frames.length === 0) + if (line.indexOf(sentinel) === -1 || frames.length === 0) continue; var frame = line.substr(line.indexOf(sentinel) + sentinel.length); diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 0ff1e2a7cf61b7..8ce757375c9516 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -36,7 +36,7 @@ exec('thisisnotavalidcommand', function(err, stdout, stderr) { if (err) { error_count++; assert.equal('', stdout); - assert.equal(true, err.code != 0); + assert.equal(true, err.code !== 0); assert.equal(false, err.killed); assert.strictEqual(null, err.signal); console.log('error code: ' + err.code); @@ -45,7 +45,7 @@ exec('thisisnotavalidcommand', function(err, stdout, stderr) { } else { success_count++; console.dir(stdout); - assert.equal(true, stdout != ''); + assert.equal(true, stdout !== ''); } }); diff --git a/test/pummel/test-http-upload-timeout.js b/test/pummel/test-http-upload-timeout.js index 08132e3c7594d1..ab27ba1a69c84f 100644 --- a/test/pummel/test-http-upload-timeout.js +++ b/test/pummel/test-http-upload-timeout.js @@ -17,7 +17,7 @@ server.on('request', function(req, res) { connections--; res.writeHead(200); res.end('done\n'); - if (connections == 0) { + if (connections === 0) { server.close(); } }); diff --git a/test/pummel/test-net-connect-econnrefused.js b/test/pummel/test-net-connect-econnrefused.js index 113b04e31f3ae1..2b6dc84f37195c 100644 --- a/test/pummel/test-net-connect-econnrefused.js +++ b/test/pummel/test-net-connect-econnrefused.js @@ -19,7 +19,7 @@ function pummel() { net.createConnection(common.PORT).on('error', function(err) { assert.equal(err.code, 'ECONNREFUSED'); if (--pending > 0) return; - if (rounds == ROUNDS) return check(); + if (rounds === ROUNDS) return check(); rounds++; pummel(); }); diff --git a/test/pummel/test-net-connect-memleak.js b/test/pummel/test-net-connect-memleak.js index 855bf1f070d7c8..1b1b32f94e23af 100644 --- a/test/pummel/test-net-connect-memleak.js +++ b/test/pummel/test-net-connect-memleak.js @@ -16,7 +16,7 @@ var before = 0; before = process.memoryUsage().rss; net.createConnection(common.PORT, '127.0.0.1', function() { - assert(junk.length != 0); // keep reference alive + assert(junk.length !== 0); // keep reference alive setTimeout(done, 10); gc(); }); diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index b70efbda582571..5741c02796f682 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -72,7 +72,7 @@ server.listen(common.PORT, function() { var finished_clients = 0; for (var i = 0; i < concurrency; i++) { runClient(function() { - if (++finished_clients == concurrency) server.close(); + if (++finished_clients === concurrency) server.close(); }); } }); diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index a7ede0b0565ac9..71c5d3e7811c71 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -16,7 +16,7 @@ function pingPongTest(port, host, on_complete) { var address = socket.remoteAddress; if (host === '127.0.0.1') { assert.equal(address, '127.0.0.1'); - } else if (host == null || host === 'localhost') { + } else if (host === null || host === undefined || host === 'localhost') { assert(address === '127.0.0.1' || address === '::ffff:127.0.0.1'); } else { console.log('host = ' + host + ', remoteAddress = ' + address); diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index 25544a6d5f5989..396fd58592c5c5 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -52,7 +52,7 @@ echo_server.listen(common.PORT, function() { client.write('hello\r\n'); }, 500); - if (exchanges == 5) { + if (exchanges === 5) { console.log('wait for timeout - should come in ' + timeout + ' ms'); starttime = new Date(); console.dir(starttime); @@ -76,8 +76,8 @@ echo_server.listen(common.PORT, function() { }); process.on('exit', function() { - assert.ok(starttime != null); - assert.ok(timeouttime != null); + assert.ok(starttime !== null && starttime !== undefined); + assert.ok(timeouttime !== null && timeouttime !== undefined); var diff = timeouttime - starttime; console.log('diff = ' + diff); diff --git a/test/pummel/test-net-timeout2.js b/test/pummel/test-net-timeout2.js index c7b445f96c4e38..6138ae7afcdfe6 100644 --- a/test/pummel/test-net-timeout2.js +++ b/test/pummel/test-net-timeout2.js @@ -21,7 +21,7 @@ var server = net.createServer(function(socket) { var interval = setInterval(function() { counter++; - if (counter == seconds) { + if (counter === seconds) { clearInterval(interval); server.close(); socket.destroy(); diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index 2225da91edcf5f..2aad6cdbf4a33b 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -41,7 +41,7 @@ setInterval(function() { assert.equal(true, t - WINDOW < diff && diff < t + WINDOW); assert.equal(true, interval_count <= 3); - if (interval_count == 3) + if (interval_count === 3) clearInterval(this); }, 1000); @@ -56,7 +56,7 @@ setInterval(function(param) { ++interval_count2; assert.equal('test param', param); - if (interval_count2 == 3) + if (interval_count2 === 3) clearInterval(this); }, 1000, 'test param'); @@ -73,7 +73,7 @@ setInterval(function(param1, param2) { assert.equal('param1', param1); assert.equal('param2', param2); - if (interval_count3 == 3) + if (interval_count3 === 3) clearInterval(this); }, 1000, 'param1', 'param2'); diff --git a/test/pummel/test-tls-connect-memleak.js b/test/pummel/test-tls-connect-memleak.js index b8ddc78fab6e4e..38a9617b789ae1 100644 --- a/test/pummel/test-tls-connect-memleak.js +++ b/test/pummel/test-tls-connect-memleak.js @@ -25,7 +25,7 @@ tls.createServer({ var options = { rejectUnauthorized: false }; tls.connect(common.PORT, '127.0.0.1', options, function() { - assert(junk.length != 0); // keep reference alive + assert(junk.length !== 0); // keep reference alive setTimeout(done, 10); gc(); }); diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js index 1d0ef77d543e43..18cef7265014c7 100644 --- a/test/pummel/test-watch-file.js +++ b/test/pummel/test-watch-file.js @@ -15,7 +15,7 @@ function watchFile() { fs.watchFile(f, function(curr, prev) { console.log(f + ' change'); changes++; - assert.ok(curr.mtime != prev.mtime); + assert.ok(curr.mtime !== prev.mtime); fs.unwatchFile(f); watchFile(); fs.unwatchFile(f); diff --git a/test/sequential/test-chdir.js b/test/sequential/test-chdir.js index bab421e1e650c4..2ad441dc01df9b 100644 --- a/test/sequential/test-chdir.js +++ b/test/sequential/test-chdir.js @@ -22,10 +22,10 @@ try { } process.chdir(dir); -assert(process.cwd() == dir); +assert(process.cwd() === dir); process.chdir('..'); -assert(process.cwd() == path.resolve(common.fixturesDir)); +assert(process.cwd() === path.resolve(common.fixturesDir)); cleanup(); assert.throws(function() { process.chdir({}); }, TypeError, 'Bad argument.'); diff --git a/test/sequential/test-regress-GH-3739.js b/test/sequential/test-regress-GH-3739.js index cc16b22dc44c46..5616b54370d91f 100644 --- a/test/sequential/test-regress-GH-3739.js +++ b/test/sequential/test-regress-GH-3739.js @@ -13,7 +13,7 @@ for (var i = 0; i < 50; i++) { try { fs.mkdirSync(dir, '0777'); } catch (e) { - if (e.code == 'EEXIST') { + if (e.code === 'EEXIST') { // Ignore; } else { cleanup(); diff --git a/test/sequential/test-regress-GH-877.js b/test/sequential/test-regress-GH-877.js index 69671b9dc4a143..599f606e57cd1f 100644 --- a/test/sequential/test-regress-GH-877.js +++ b/test/sequential/test-regress-GH-877.js @@ -25,7 +25,7 @@ server.listen(common.PORT, '127.0.0.1', function() { }; var req = http.get(options, function(res) { - if (++responses == N) { + if (++responses === N) { server.close(); } res.resume(); @@ -47,6 +47,6 @@ server.listen(common.PORT, '127.0.0.1', function() { }); process.on('exit', function() { - assert.ok(responses == N); + assert.ok(responses === N); assert.ok(maxQueued <= 10); }); diff --git a/test/sequential/test-tcp-wrap-listen.js b/test/sequential/test-tcp-wrap-listen.js index a2c07a7a9ce2a2..477a7f9dbd95e2 100644 --- a/test/sequential/test-tcp-wrap-listen.js +++ b/test/sequential/test-tcp-wrap-listen.js @@ -22,7 +22,7 @@ server.onconnection = function(err, client) { console.log('got connection'); function maybeCloseClient() { - if (client.pendingWrites.length == 0 && client.gotEOF) { + if (client.pendingWrites.length === 0 && client.gotEOF) { console.log('close client'); client.close(); }