Skip to content

Commit 724910a

Browse files
TrottMylesBorins
authored andcommitted
debugger: refactor _debugger.js
* `==` -> `===` * use white space in array to improve readability PR-URL: #9860 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b5eae44 commit 724910a

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

lib/_debugger.js

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Client.prototype._addScript = function(desc) {
186186
this.scripts[desc.id] = desc;
187187
if (desc.name) {
188188
desc.isNative = (desc.name.replace('.js', '') in natives) ||
189-
desc.name == 'node.js';
189+
desc.name === 'node.js';
190190
}
191191
};
192192

@@ -201,7 +201,7 @@ Client.prototype._onResponse = function(res) {
201201
var index = -1;
202202

203203
this._reqCallbacks.some(function(fn, i) {
204-
if (fn.request_seq == res.body.request_seq) {
204+
if (fn.request_seq === res.body.request_seq) {
205205
cb = fn;
206206
index = i;
207207
return true;
@@ -211,25 +211,25 @@ Client.prototype._onResponse = function(res) {
211211
var self = this;
212212
var handled = false;
213213

214-
if (res.headers.Type == 'connect') {
214+
if (res.headers.Type === 'connect') {
215215
// Request a list of scripts for our own storage.
216216
self.reqScripts();
217217
self.emit('ready');
218218
handled = true;
219219

220-
} else if (res.body && res.body.event == 'break') {
220+
} else if (res.body && res.body.event === 'break') {
221221
this.emit('break', res.body);
222222
handled = true;
223223

224-
} else if (res.body && res.body.event == 'exception') {
224+
} else if (res.body && res.body.event === 'exception') {
225225
this.emit('exception', res.body);
226226
handled = true;
227227

228-
} else if (res.body && res.body.event == 'afterCompile') {
228+
} else if (res.body && res.body.event === 'afterCompile') {
229229
this._addHandle(res.body.body.script);
230230
handled = true;
231231

232-
} else if (res.body && res.body.event == 'scriptCollected') {
232+
} else if (res.body && res.body.event === 'scriptCollected') {
233233
// ???
234234
this._removeScript(res.body.body.script);
235235
handled = true;
@@ -327,7 +327,7 @@ Client.prototype.reqScopes = function(cb) {
327327
Client.prototype.reqEval = function(expression, cb) {
328328
var self = this;
329329

330-
if (this.currentFrame == NO_FRAME) {
330+
if (this.currentFrame === NO_FRAME) {
331331
// Only need to eval in global scope.
332332
this.reqFrameEval(expression, NO_FRAME, cb);
333333
return;
@@ -357,7 +357,7 @@ Client.prototype.reqEval = function(expression, cb) {
357357

358358
// Finds the first scope in the array in which the expression evals.
359359
Client.prototype._reqFramesEval = function(expression, evalFrames, cb) {
360-
if (evalFrames.length == 0) {
360+
if (evalFrames.length === 0) {
361361
// Just eval in global scope.
362362
this.reqFrameEval(expression, NO_FRAME, cb);
363363
return;
@@ -381,7 +381,7 @@ Client.prototype.reqFrameEval = function(expression, frame, cb) {
381381
arguments: { expression: expression }
382382
};
383383

384-
if (frame == NO_FRAME) {
384+
if (frame === NO_FRAME) {
385385
req.arguments.global = true;
386386
} else {
387387
req.arguments.frame = frame;
@@ -528,9 +528,9 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
528528
var mirror;
529529
var waiting = 1;
530530

531-
if (handle.className == 'Array') {
531+
if (handle.className === 'Array') {
532532
mirror = [];
533-
} else if (handle.className == 'Date') {
533+
} else if (handle.className === 'Date') {
534534
mirror = new Date(handle.value);
535535
} else {
536536
mirror = {};
@@ -770,10 +770,20 @@ function Interface(stdin, stdout, args) {
770770
process.once('SIGHUP', process.exit.bind(process, 0));
771771

772772
var proto = Interface.prototype;
773-
const ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
774-
'requireConnection', 'killChild', 'trySpawn',
775-
'controlEval', 'debugEval', 'print', 'childPrint',
776-
'clearline'];
773+
const ignored = [
774+
'pause',
775+
'resume',
776+
'exitRepl',
777+
'handleBreak',
778+
'requireConnection',
779+
'killChild',
780+
'trySpawn',
781+
'controlEval',
782+
'debugEval',
783+
'print',
784+
'childPrint',
785+
'clearline'
786+
];
777787
const shortcut = {
778788
'run': 'r',
779789
'cont': 'c',
@@ -1093,14 +1103,14 @@ Interface.prototype.list = function(delta) {
10931103
var lineno = res.fromLine + i + 1;
10941104
if (lineno < from || lineno > to) continue;
10951105

1096-
const current = lineno == 1 + client.currentSourceLine;
1106+
const current = lineno === 1 + client.currentSourceLine;
10971107
const breakpoint = client.breakpoints.some(function(bp) {
10981108
return (bp.scriptReq === client.currentScript ||
10991109
bp.script === client.currentScript) &&
1100-
bp.line == lineno;
1110+
bp.line === lineno;
11011111
});
11021112

1103-
if (lineno == 1) {
1113+
if (lineno === 1) {
11041114
// The first line needs to have the module wrapper filtered out of
11051115
// it.
11061116
var wrapper = Module.wrapper[0];
@@ -1147,7 +1157,7 @@ Interface.prototype.backtrace = function() {
11471157
return;
11481158
}
11491159

1150-
if (bt.totalFrames == 0) {
1160+
if (bt.totalFrames === 0) {
11511161
self.print('(empty stack)');
11521162
} else {
11531163
const trace = [];
@@ -1189,10 +1199,10 @@ Interface.prototype.scripts = function() {
11891199
var script = client.scripts[id];
11901200
if (script !== null && typeof script === 'object' && script.name) {
11911201
if (displayNatives ||
1192-
script.name == client.currentScript ||
1202+
script.name === client.currentScript ||
11931203
!script.isNative) {
11941204
scripts.push(
1195-
(script.name == client.currentScript ? '* ' : ' ') +
1205+
(script.name === client.currentScript ? '* ' : ' ') +
11961206
id + ': ' +
11971207
path.basename(script.name)
11981208
);

0 commit comments

Comments
 (0)