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>
This commit is contained in:
parent
1d21c05a67
commit
34a6c858bd
@ -187,7 +187,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';
|
||||
}
|
||||
};
|
||||
|
||||
@ -202,7 +202,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;
|
||||
@ -212,25 +212,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;
|
||||
@ -328,7 +328,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;
|
||||
@ -358,7 +358,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;
|
||||
@ -382,7 +382,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;
|
||||
@ -529,9 +529,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 = {};
|
||||
@ -774,10 +774,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',
|
||||
@ -1097,14 +1107,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];
|
||||
@ -1151,7 +1161,7 @@ Interface.prototype.backtrace = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bt.totalFrames == 0) {
|
||||
if (bt.totalFrames === 0) {
|
||||
self.print('(empty stack)');
|
||||
} else {
|
||||
const trace = [];
|
||||
@ -1193,10 +1203,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…
x
Reference in New Issue
Block a user