lib: reduce util.is*() usage

Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).

Fixes: https://github.com/iojs/io.js/issues/607
PR-URL: https://github.com/iojs/io.js/pull/647
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
cjihrig committed 2015-01-31 23:47:29 -05:00
1 parent bce7a2608e
commit 6ac8bdc0ab
37 files changed
+451 -445

No files matched your search

+8 -8
View File
@@ -4,7 +4,7 @@ const tls = require('tls');
const url = require('url');
const http = require('http');
const util = require('util');
const inherits = require('util').inherits;
const inherits = util.inherits;
const debug = util.debuglog('https');
function Server(opts, requestListener) {
@@ -41,21 +41,21 @@ exports.createServer = function(opts, requestListener) {
// HTTPS agents.
function createConnection(port, host, options) {
if (util.isObject(port)) {
if (port !== null && typeof port === 'object') {
options = port;
} else if (util.isObject(host)) {
} else if (host !== null && typeof host === 'object') {
options = host;
} else if (util.isObject(options)) {
} else if (options !== null && typeof options === 'object') {
options = options;
} else {
options = {};
}
if (util.isNumber(port)) {
if (typeof port === 'number') {
options.port = port;
}
if (util.isString(host)) {
if (typeof host === 'string') {
options.host = host;
}
@@ -96,7 +96,7 @@ Agent.prototype.getName = function(options) {
name += options.pfx;
name += ':';
if (!util.isUndefined(options.rejectUnauthorized))
if (options.rejectUnauthorized !== undefined)
name += options.rejectUnauthorized;
return name;
@@ -108,7 +108,7 @@ exports.globalAgent = globalAgent;
exports.Agent = Agent;
exports.request = function(options, cb) {
if (util.isString(options)) {
if (typeof options === 'string') {
options = url.parse(options);
} else {
options = util._extend({}, options);