diff options
| author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-24 18:03:53 +0200 |
|---|---|---|
| committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-24 21:49:35 +0200 |
| commit | 0330bdf5195eb77f04c26a09a8bd2088a261fe53 (patch) | |
| tree | 2c13f9f1757bca93e83e425a028dcae78549f40e /lib/_debugger.js | |
| parent | 457d52924152c6f2baf2fddbe76a03bca7bdde7c (diff) | |
| download | node-0330bdf5195eb77f04c26a09a8bd2088a261fe53.tar.gz | |
lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
Diffstat (limited to 'lib/_debugger.js')
| -rw-r--r-- | lib/_debugger.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/_debugger.js b/lib/_debugger.js index 10096b5ea..993fcba28 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -182,7 +182,7 @@ exports.Client = Client; Client.prototype._addHandle = function(desc) { - if (typeof desc != 'object' || typeof desc.handle != 'number') { + if (!IS_OBJECT(desc) || !IS_NUMBER(desc.handle)) { return; } @@ -296,7 +296,7 @@ Client.prototype.reqLookup = function(refs, cb) { this.req(req, function(err, res) { if (err) return cb(err); for (var ref in res) { - if (typeof res[ref] == 'object') { + if (IS_OBJECT(res[ref])) { self._addHandle(res[ref]); } } @@ -559,8 +559,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) { } - if (Array.isArray(mirror) && - typeof prop.name != 'number') { + if (IS_ARRAY(mirror) && !IS_NUMBER(prop.name)) { // Skip the 'length' property. return; } @@ -593,7 +592,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) { val = function() {}; } else if (handle.type === 'null') { val = null; - } else if (handle.value !== undefined) { + } else if (!IS_UNDEFINED(handle.value)) { val = handle.value; } else if (handle.type === 'undefined') { val = undefined; @@ -892,7 +891,7 @@ Interface.prototype.print = function(text, oneline) { if (this.killed) return; this.clearline(); - this.stdout.write(typeof text === 'string' ? text : util.inspect(text)); + this.stdout.write(IS_STRING(text) ? text : util.inspect(text)); if (oneline !== true) { this.stdout.write('\n'); @@ -1214,7 +1213,7 @@ Interface.prototype.scripts = function() { this.pause(); for (var id in client.scripts) { var script = client.scripts[id]; - if (typeof script == 'object' && script.name) { + if (IS_OBJECT(script) && script.name) { if (displayNatives || script.name == client.currentScript || !script.isNative) { @@ -1351,13 +1350,13 @@ Interface.prototype.setBreakpoint = function(script, line, ambiguous; // setBreakpoint() should insert breakpoint on current line - if (script === undefined) { + if (IS_UNDEFINED(script)) { script = this.client.currentScript; line = this.client.currentSourceLine + 1; } // setBreakpoint(line-number) should insert breakpoint in current script - if (line === undefined && typeof script === 'number') { + if (IS_UNDEFINED(line) && IS_NUMBER(script)) { line = script; script = this.client.currentScript; } @@ -1452,7 +1451,7 @@ Interface.prototype.clearBreakpoint = function(script, line) { if (bp.scriptId === script || bp.scriptReq === script || (bp.script && bp.script.indexOf(script) !== -1)) { - if (index !== undefined) { + if (!IS_UNDEFINED(index)) { ambiguous = true; } if (bp.line === line) { @@ -1465,7 +1464,7 @@ Interface.prototype.clearBreakpoint = function(script, line) { if (ambiguous) return this.error('Script name is ambiguous'); - if (breakpoint === undefined) { + if (IS_UNDEFINED(breakpoint)) { return this.error('Script : ' + script + ' not found'); } |
