Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force strict comparison #2392

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand All @@ -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';
}
};

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -1150,7 +1150,7 @@ Interface.prototype.backtrace = function() {
return;
}

if (bt.totalFrames == 0) {
if (bt.totalFrames === 0) {
self.print('(empty stack)');
} else {
var trace = [],
Expand Down Expand Up @@ -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)
);
Expand Down Expand Up @@ -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] &&
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/_linklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/_stream_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 7 additions & 7 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ 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;
handle.send = handle.send6;
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');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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');

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
8 changes: 4 additions & 4 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ win32.relative = function(from, to) {
}
}

if (samePartsLength == 0) {
if (samePartsLength === 0) {
return to;
}

Expand Down
Loading