diff --git a/lib/_debugger.js b/lib/_debugger.js index b90d8fbe9c6..d60a3f5c369 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -209,6 +209,7 @@ Client.prototype._onResponse = function(res) { index = i; return true; } + return null; }); var self = this; @@ -259,7 +260,7 @@ Client.prototype.reqVersion = function(cb) { cb = cb || function () {}; this.req({ command: 'version' } , function(err, body, res) { if (err) return cb(err); - cb(null, res.body.body.V8Version, res.body.running); + return cb(null, res.body.body.V8Version, res.body.running); }); }; @@ -285,7 +286,7 @@ Client.prototype.reqLookup = function(refs, cb) { } } - cb(null, res); + return cb(null, res); }); }; @@ -303,7 +304,7 @@ Client.prototype.reqScopes = function(cb) { return scope.object.ref; }); - self.reqLookup(refs, function(err, res) { + return self.reqLookup(refs, function(err, res) { if (err) return cb(err); var globals = Object.keys(res).map(function(key) { @@ -312,7 +313,7 @@ Client.prototype.reqScopes = function(cb) { }); }); - cb(null, globals.reverse()); + return cb(null, globals.reverse()); }); }); }; @@ -339,13 +340,13 @@ Client.prototype.reqEval = function(expression, cb) { var frame = bt.frames[self.currentFrame]; var evalFrames = frame.scopes.map(function(s) { - if (!s) return; + if (!s) return null; var x = bt.frames[s.index]; - if (!x) return; + if (!x) return null; return x.index; }); - self._reqFramesEval(expression, evalFrames, cb); + return self._reqFramesEval(expression, evalFrames, cb); }); }; @@ -364,7 +365,7 @@ Client.prototype._reqFramesEval = function(expression, evalFrames, cb) { cb = cb || function () {}; this.reqFrameEval(expression, i, function(err, res) { if (!err) return cb(null, res); - self._reqFramesEval(expression, evalFrames, cb); + return self._reqFramesEval(expression, evalFrames, cb); }); }; @@ -423,7 +424,7 @@ Client.prototype.reqScripts = function(cb) { for (var i = 0; i < res.length; i++) { self._addHandle(res[i]); } - cb(null); + return cb(null); }); }; @@ -438,7 +439,7 @@ Client.prototype.listbreakpoints = function(cb) { }; Client.prototype.setBreakpoint = function(req, cb) { - var req = { + req = { command: 'setbreakpoint', arguments: req }; @@ -447,7 +448,7 @@ Client.prototype.setBreakpoint = function(req, cb) { }; Client.prototype.clearBreakpoint = function(req, cb) { - var req = { + req = { command: 'clearbreakpoint', arguments: req }; @@ -612,7 +613,7 @@ Client.prototype.fullTrace = function(cb) { refs.push(frame.receiver.ref); } - self.reqLookup(refs, function(err, res) { + return self.reqLookup(refs, function(err, res) { if (err) return cb(err); for (var i = 0; i < trace.frames.length; i++) { @@ -622,7 +623,7 @@ Client.prototype.fullTrace = function(cb) { frame.receiver = res[frame.receiver.ref]; } - cb(null, trace); + return cb(null, trace); }); }); }; diff --git a/lib/buffer.js b/lib/buffer.js index 25dfaab042c..c1b07b635dd 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -988,13 +988,13 @@ Buffer.prototype.writeInt8 = function(value, offset, noAssert) { assert.ok(offset < buffer.length, 'Trying to write beyond buffer length'); - verifsint(value, 0x7f, -0xf0); + verifsint(value, 127, -240); } if (value >= 0) { buffer.writeUInt8(value, offset, noAssert); } else { - buffer.writeUInt8(0xff + value + 1, offset, noAssert); + buffer.writeUInt8(255 + value + 1, offset, noAssert); } }; @@ -1012,13 +1012,13 @@ function writeInt16(buffer, value, offset, isBigEndian, noAssert) { assert.ok(offset + 1 < buffer.length, 'Trying to write beyond buffer length'); - verifsint(value, 0x7fff, -0xf000); + verifsint(value, 32767, -61440); } if (value >= 0) { writeUInt16(buffer, value, offset, isBigEndian, noAssert); } else { - writeUInt16(buffer, 0xffff + value + 1, offset, isBigEndian, noAssert); + writeUInt16(buffer, 65535 + value + 1, offset, isBigEndian, noAssert); } } @@ -1044,13 +1044,13 @@ function writeInt32(buffer, value, offset, isBigEndian, noAssert) { assert.ok(offset + 3 < buffer.length, 'Trying to write beyond buffer length'); - verifsint(value, 0x7fffffff, -0xf0000000); + verifsint(value, 2147483647, -4026531840); } if (value >= 0) { writeUInt32(buffer, value, offset, isBigEndian, noAssert); } else { - writeUInt32(buffer, 0xffffffff + value + 1, offset, isBigEndian, noAssert); + writeUInt32(buffer, 2147483647 + value + 1, offset, isBigEndian, noAssert); } } @@ -1079,8 +1079,7 @@ function writeFloat(buffer, value, offset, isBigEndian, noAssert) { verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38); } - require('buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian, - 23, 4); + require('buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian, 23, 4); } Buffer.prototype.writeFloatLE = function(value, offset, noAssert) { diff --git a/lib/buffer_ieee754.js b/lib/buffer_ieee754.js index 7a86b2f2948..fcdefe435f8 100644 --- a/lib/buffer_ieee754.js +++ b/lib/buffer_ieee754.js @@ -37,29 +37,23 @@ exports.readIEEE754 = function(buffer, offset, isBE, mLen, nBytes) { eBias = eMax >> 1, nBits = -7, i = isBE ? 0 : (nBytes - 1), - d = isBE ? 1 : -1, s = buffer[offset + i]; - i += d; + i += d = isBE ? 1 : -1; - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); + e = s & (1 << -nBits) - 1; + s >>= -nBits; nBits += eLen; for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); - m = e & ((1 << (-nBits)) - 1); - e >>= (-nBits); + m = e & (1 << -nBits) - 1; + e >>= -nBits; nBits += mLen; for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); - if (e === 0) { - e = 1 - eBias; - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity); - } else { - m = m + Math.pow(2, mLen); - e = e - eBias; - } + if (e === 0) e = 1 - eBias; + else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity; + else m = m + Math.pow(2, mLen), e = e - eBias; return (s ? -1 : 1) * m * Math.pow(2, e - mLen); }; @@ -75,42 +69,17 @@ exports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) { value = Math.abs(value); - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; - } else { + if (isNaN(value) || value === Infinity) m = isNaN(value) ? 1 : 0, e = eMax; + else { e = Math.floor(Math.log(value) / Math.LN2); - if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; - } - if (e+eBias >= 1) { - value += rt / c; - } else { - value += rt * Math.pow(2, 1 - eBias); - } - if (value * c >= 2) { - e++; - c /= 2; - } - - if (e + eBias >= eMax) { - m = 0; - e = eMax; - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e = e + eBias; - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; - } + if (value * (c = Math.pow(2, -e)) < 1) e--, c *= 2; + value += e + eBias >= 1 ? rt / c : rt * Math.pow(2, 1 - eBias); + value * c >= 2 && ( e++, c /= 2 ); + e + eBias >= eMax ? ( m = 0, e = eMax ) : e + eBias >= 1 ? ( m = (value * c - 1) * Math.pow(2, mLen), e = e + eBias) : (m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen), e = 0 ); } - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); - + for (; mLen >= 8; buffer[offset + i] = m & 256, i += d, m /= 256, mLen -= 8); e = (e << mLen) | m; - eLen += mLen; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); - + for (eLen += mLen; eLen > 0; buffer[offset + i] = e & 256, i += d, e /= 256, eLen -= 8); buffer[offset + i - d] |= s * 128; }; diff --git a/lib/child_process_legacy.js b/lib/child_process_legacy.js index edcbaa0a73c..0da58269663 100644 --- a/lib/child_process_legacy.js +++ b/lib/child_process_legacy.js @@ -181,18 +181,12 @@ exports.execFile = function(file /* args, options, callback */) { child.stdout.addListener('data', function(chunk) { stdout += chunk; - if (stdout.length > options.maxBuffer) { - err = new Error('maxBuffer exceeded.'); - kill(); - } + ( stdout.length > options.maxBuffer ) && (err = new Error('maxBuffer exceeded.'), kill()); }); child.stderr.addListener('data', function(chunk) { stderr += chunk; - if (stderr.length > options.maxBuffer) { - err = new Error('maxBuffer exceeded.'); - kill(); - } + ( stderr.length > options.maxBuffer ) && ( err = new Error('maxBuffer exceeded.'), kill() ); }); child.addListener('exit', exithandler); @@ -266,27 +260,9 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) { args = args || []; var cwd, env, setsid, uid, gid; - if (!options || options.cwd === undefined && - options.env === undefined && - options.customFds === undefined && - options.gid === undefined && - options.uid === undefined) { - // Deprecated API: (path, args, options, env, customFds) - cwd = ''; - env = options || process.env; - customFds = customFds || [-1, -1, -1]; - setsid = false; - uid = -1; - gid = -1; - } else { - // Recommended API: (path, args, options) - cwd = options.cwd || ''; - env = options.env || process.env; - customFds = options.customFds || [-1, -1, -1]; - setsid = options.setsid ? true : false; - uid = options.hasOwnProperty('uid') ? options.uid : -1; - gid = options.hasOwnProperty('gid') ? options.gid : -1; - } + !options || options.cwd === void 0 && options.env === void 0 && options.customFds === void 0 && options.gid === void 0 && options.uid === void 0 ? + ( cwd = '', env = options || process.env, customFds = customFds || [-1, -1, -1], setsid = false, uid = -1, gid = -1 ) : // Deprecated API: (path, args, options, env, customFds) + (cwd = options.cwd || '', env = options.env || process.env, customFds = options.customFds || [-1, -1, -1], setsid = options.setsid ? true : false, uid = options.hasOwnProperty('uid') ? options.uid : -1, gid = options.hasOwnProperty('gid') ? options.gid : -1); // Recommended API: (path, args, options) var envPairs = []; var keys = Object.keys(env); @@ -310,7 +286,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) { gid); this.fds = fds; - if (customFds[0] === -1 || customFds[0] === undefined) { + if (customFds[0] === -1 || customFds[0] === void 0) { this.stdin.open(fds[0]); this.stdin.writable = true; this.stdin.readable = false; @@ -318,7 +294,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) { this.stdin = null; } - if (customFds[1] === -1 || customFds[1] === undefined) { + if (customFds[1] === -1 || customFds[1] === void 0) { this.stdout.open(fds[1]); this.stdout.writable = false; this.stdout.readable = true; @@ -327,7 +303,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) { this.stdout = null; } - if (customFds[2] === -1 || customFds[2] === undefined) { + if (customFds[2] === -1 || customFds[2] === void 0) { this.stderr.open(fds[2]); this.stderr.writable = false; this.stderr.readable = true; diff --git a/lib/fs.js b/lib/fs.js index 60b2930f2a0..294c52534ed 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -105,7 +105,7 @@ fs.readFile = function(path, encoding_) { return callback(er); } } - callback(null, buffer); + return callback(null, buffer); }); }; @@ -411,8 +411,7 @@ fs.readlinkSync = function(path) { fs.symlink = function(destination, path, mode_, callback) { var mode = (typeof(mode_) == 'string' ? mode_ : null); - var callback_ = arguments[arguments.length - 1]; - var callback = (typeof(callback_) == 'function' ? callback_ : null); + callback = (typeof(callback) == 'function' ? callback : null); binding.symlink(destination, path, mode, callback); }; @@ -563,8 +562,7 @@ function writeAll(fd, buffer, offset, length, callback) { fs.writeFile = function(path, data, encoding_, callback) { var encoding = (typeof(encoding_) == 'string' ? encoding_ : 'utf8'); - var callback_ = arguments[arguments.length - 1]; - var callback = (typeof(callback_) == 'function' ? callback_ : null); + callback = (typeof(callback) == 'function' ? callback : null); fs.open(path, 'w', 0666, function(openErr, fd) { if (openErr) { if (callback) callback(openErr); @@ -746,7 +744,7 @@ if (isWindows) { // windows version fs.realpathSync = function realpathSync(p, cache) { - var p = path.resolve(p); + p = path.resolve(p); if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { return cache[p]; } @@ -761,7 +759,7 @@ if (isWindows) { cb = cache; cache = null; } - var p = path.resolve(p); + p = path.resolve(p); if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { return cb(null, cache[p]); } @@ -770,6 +768,7 @@ if (isWindows) { if (cache) cache[p] = p; cb(null, p); }); + return null; }; @@ -933,7 +932,9 @@ if (isWindows) { fs.readlink(base, function(err, target) { gotTarget(err, seenLinks[id] = target); }); + return null; }); + return null; } function gotTarget(err, target, base) { @@ -941,7 +942,7 @@ if (isWindows) { var resolvedLink = path.resolve(previous, target); if (cache) cache[base] = resolvedLink; - gotResolvedLink(resolvedLink); + return gotResolvedLink(resolvedLink); } function gotResolvedLink(resolvedLink) { @@ -953,6 +954,7 @@ if (isWindows) { return process.nextTick(LOOP); } + return null; }; } @@ -1011,7 +1013,7 @@ var ReadStream = fs.ReadStream = function(path, options) { } if (this.fd !== null) { - return; + return null; } fs.open(this.path, this.flags, this.mode, function(err, fd) { @@ -1025,6 +1027,7 @@ var ReadStream = fs.ReadStream = function(path, options) { self.emit('open', fd); self._read(); }); + return null; }; util.inherits(ReadStream, Stream); @@ -1335,3 +1338,4 @@ WriteStream.prototype.destroy = function(cb) { // There is no shutdown() for files. WriteStream.prototype.destroySoon = WriteStream.prototype.end; + diff --git a/lib/http.js b/lib/http.js index efa0963be33..aa3e94036ad 100644 --- a/lib/http.js +++ b/lib/http.js @@ -604,7 +604,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) { if (this.chunkedEncoding) { if (typeof(chunk) === 'string') { len = Buffer.byteLength(chunk, encoding); - var chunk = len.toString(16) + CRLF + chunk + CRLF; + chunk = len.toString(16) + CRLF + chunk + CRLF; ret = this._send(chunk, encoding); } else { // buffer @@ -1726,7 +1726,7 @@ exports.cat = function(url, encoding_, headers_) { } } - var url = require('url').parse(url); + url = require('url').parse(url); var hasHost = false; if (Array.isArray(headers)) { diff --git a/lib/http2.js b/lib/http2.js index a42a613c133..755f94b95c8 100644 --- a/lib/http2.js +++ b/lib/http2.js @@ -604,7 +604,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) { if (this.chunkedEncoding) { if (typeof(chunk) === 'string') { len = Buffer.byteLength(chunk, encoding); - var chunk = len.toString(16) + CRLF + chunk + CRLF; + chunk = len.toString(16) + CRLF + chunk + CRLF; ret = this._send(chunk, encoding); } else { // buffer diff --git a/lib/readline.js b/lib/readline.js index 21422581096..66884aa1430 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -105,6 +105,7 @@ function Interface(input, output, completer) { }); } } + return null; } inherits(Interface, EventEmitter); @@ -316,7 +317,7 @@ Interface.prototype._tabComplete = function() { // If there is a common prefix to all matches, then apply that // portion. - var f = completions.filter(function(e) { if (e) return e; }); + var f = completions.filter(function(e) { return !!e; }); var prefix = commonPrefix(f); if (prefix.length > completeOn.length) { self._insertString(prefix.slice(completeOn.length)); diff --git a/lib/repl.js b/lib/repl.js index de380929f50..91ad07b6960 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -183,6 +183,7 @@ function REPLServer(prompt, stream, eval) { } else { finish(null, ret); } + return null; }); } else { diff --git a/lib/tls.js b/lib/tls.js index 6f26ffb4551..82b53b73d4c 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -916,6 +916,7 @@ Server.prototype.SNICallback = function(servername) { ctx = elem[1]; return true; } + return null; }); return ctx; diff --git a/lib/zlib.js b/lib/zlib.js index 43725bff2d2..7ee7d2bee61 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -93,12 +93,12 @@ exports.createUnzip = function(o) { // minimal 2-byte header function Deflate(opts) { if (!(this instanceof Deflate)) return new Deflate(opts); - Zlib.call(this, opts, binding.Deflate); + return Zlib.call(this, opts, binding.Deflate); } function Inflate(opts) { if (!(this instanceof Inflate)) return new Inflate(opts); - Zlib.call(this, opts, binding.Inflate); + return Zlib.call(this, opts, binding.Inflate); } @@ -106,12 +106,12 @@ function Inflate(opts) { // gzip - bigger header, same deflate compression function Gzip(opts) { if (!(this instanceof Gzip)) return new Gzip(opts); - Zlib.call(this, opts, binding.Gzip); + return Zlib.call(this, opts, binding.Gzip); } function Gunzip(opts) { if (!(this instanceof Gunzip)) return new Gunzip(opts); - Zlib.call(this, opts, binding.Gunzip); + return Zlib.call(this, opts, binding.Gunzip); } @@ -119,19 +119,19 @@ function Gunzip(opts) { // raw - no header function DeflateRaw(opts) { if (!(this instanceof DeflateRaw)) return new DeflateRaw(opts); - Zlib.call(this, opts, binding.DeflateRaw); + return Zlib.call(this, opts, binding.DeflateRaw); } function InflateRaw(opts) { if (!(this instanceof InflateRaw)) return new InflateRaw(opts); - Zlib.call(this, opts, binding.InflateRaw); + return Zlib.call(this, opts, binding.InflateRaw); } // auto-detect header. function Unzip(opts) { if (!(this instanceof Unzip)) return new Unzip(opts); - Zlib.call(this, opts, binding.Unzip); + return Zlib.call(this, opts, binding.Unzip); }