Skip to content

Commit ac8d212

Browse files
TrottFishrock123
authored andcommittedDec 5, 2016
debugger: refactor _debugger.js
* `==` -> `===` * use white space in array to improve readability PR-URL: #9860 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 346204d commit ac8d212

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed
 

‎lib/_debugger.js

+32-22
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Client.prototype._addScript = function(desc) {
187187
this.scripts[desc.id] = desc;
188188
if (desc.name) {
189189
desc.isNative = (desc.name.replace('.js', '') in natives) ||
190-
desc.name == 'node.js';
190+
desc.name === 'node.js';
191191
}
192192
};
193193

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

204204
this._reqCallbacks.some(function(fn, i) {
205-
if (fn.request_seq == res.body.request_seq) {
205+
if (fn.request_seq === res.body.request_seq) {
206206
cb = fn;
207207
index = i;
208208
return true;
@@ -212,25 +212,25 @@ Client.prototype._onResponse = function(res) {
212212
var self = this;
213213
var handled = false;
214214

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

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

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

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

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

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

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

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

532-
if (handle.className == 'Array') {
532+
if (handle.className === 'Array') {
533533
mirror = [];
534-
} else if (handle.className == 'Date') {
534+
} else if (handle.className === 'Date') {
535535
mirror = new Date(handle.value);
536536
} else {
537537
mirror = {};
@@ -774,10 +774,20 @@ function Interface(stdin, stdout, args) {
774774
process.once('SIGHUP', process.exit.bind(process, 0));
775775

776776
var proto = Interface.prototype;
777-
const ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
778-
'requireConnection', 'killChild', 'trySpawn',
779-
'controlEval', 'debugEval', 'print', 'childPrint',
780-
'clearline'];
777+
const ignored = [
778+
'pause',
779+
'resume',
780+
'exitRepl',
781+
'handleBreak',
782+
'requireConnection',
783+
'killChild',
784+
'trySpawn',
785+
'controlEval',
786+
'debugEval',
787+
'print',
788+
'childPrint',
789+
'clearline'
790+
];
781791
const shortcut = {
782792
'run': 'r',
783793
'cont': 'c',
@@ -1097,14 +1107,14 @@ Interface.prototype.list = function(delta) {
10971107
var lineno = res.fromLine + i + 1;
10981108
if (lineno < from || lineno > to) continue;
10991109

1100-
const current = lineno == 1 + client.currentSourceLine;
1110+
const current = lineno === 1 + client.currentSourceLine;
11011111
const breakpoint = client.breakpoints.some(function(bp) {
11021112
return (bp.scriptReq === client.currentScript ||
11031113
bp.script === client.currentScript) &&
1104-
bp.line == lineno;
1114+
bp.line === lineno;
11051115
});
11061116

1107-
if (lineno == 1) {
1117+
if (lineno === 1) {
11081118
// The first line needs to have the module wrapper filtered out of
11091119
// it.
11101120
var wrapper = Module.wrapper[0];
@@ -1151,7 +1161,7 @@ Interface.prototype.backtrace = function() {
11511161
return;
11521162
}
11531163

1154-
if (bt.totalFrames == 0) {
1164+
if (bt.totalFrames === 0) {
11551165
self.print('(empty stack)');
11561166
} else {
11571167
const trace = [];
@@ -1193,10 +1203,10 @@ Interface.prototype.scripts = function() {
11931203
var script = client.scripts[id];
11941204
if (script !== null && typeof script === 'object' && script.name) {
11951205
if (displayNatives ||
1196-
script.name == client.currentScript ||
1206+
script.name === client.currentScript ||
11971207
!script.isNative) {
11981208
scripts.push(
1199-
(script.name == client.currentScript ? '* ' : ' ') +
1209+
(script.name === client.currentScript ? '* ' : ' ') +
12001210
id + ': ' +
12011211
path.basename(script.name)
12021212
);

0 commit comments

Comments
 (0)
Please sign in to comment.