Browse Source

debugger: refactor _debugger.js

* `==` -> `===`
* use white space in array to improve readability

PR-URL: https://github.com/nodejs/node/pull/9860
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
v4.x
Rich Trott 8 years ago
committed by Myles Borins
parent
commit
724910a991
  1. 54
      lib/_debugger.js

54
lib/_debugger.js

@ -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) {
var 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;
var 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 = {};
@ -770,10 +770,20 @@ function Interface(stdin, stdout, args) {
process.once('SIGHUP', process.exit.bind(process, 0));
var proto = Interface.prototype;
const ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
'requireConnection', 'killChild', 'trySpawn',
'controlEval', 'debugEval', 'print', 'childPrint',
'clearline'];
const ignored = [
'pause',
'resume',
'exitRepl',
'handleBreak',
'requireConnection',
'killChild',
'trySpawn',
'controlEval',
'debugEval',
'print',
'childPrint',
'clearline'
];
const shortcut = {
'run': 'r',
'cont': 'c',
@ -1093,14 +1103,14 @@ Interface.prototype.list = function(delta) {
var lineno = res.fromLine + i + 1;
if (lineno < from || lineno > to) continue;
const current = lineno == 1 + client.currentSourceLine;
const current = lineno === 1 + client.currentSourceLine;
const 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];
@ -1147,7 +1157,7 @@ Interface.prototype.backtrace = function() {
return;
}
if (bt.totalFrames == 0) {
if (bt.totalFrames === 0) {
self.print('(empty stack)');
} else {
const trace = [];
@ -1189,10 +1199,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)
);

Loading…
Cancel
Save