Skip to content

Commit 7255034

Browse files
committed
[Refactor] remove unneeded elses.
1 parent 521d345 commit 7255034

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
3939
}
4040
return String(obj);
4141
}
42-
else if (typeof obj === 'function') {
42+
if (typeof obj === 'function') {
4343
var name = nameOf(obj);
4444
return '[Function' + (name ? ': ' + name : '') + ']';
4545
}
46-
else if (obj === null) {
46+
if (obj === null) {
4747
return 'null';
4848
}
49-
else if (isSymbol(obj)) {
49+
if (isSymbol(obj)) {
5050
var symString = Symbol.prototype.toString.call(obj);
5151
return typeof obj === 'object' ? 'Object(' + symString + ')' : symString;
5252
}
53-
else if (isElement(obj)) {
53+
if (isElement(obj)) {
5454
var s = '<' + String(obj.nodeName).toLowerCase();
5555
var attrs = obj.attributes || [];
5656
for (var i = 0; i < attrs.length; i++) {
@@ -61,15 +61,15 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
6161
s += '</' + String(obj.nodeName).toLowerCase() + '>';
6262
return s;
6363
}
64-
else if (isArray(obj)) {
64+
if (isArray(obj)) {
6565
if (obj.length === 0) return '[]';
6666
var xs = Array(obj.length);
6767
for (var i = 0; i < obj.length; i++) {
6868
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
6969
}
7070
return '[ ' + xs.join(', ') + ' ]';
7171
}
72-
else if (isError(obj)) {
72+
if (isError(obj)) {
7373
var parts = [];
7474
for (var key in obj) {
7575
if (!has(obj, key)) continue;
@@ -84,36 +84,36 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
8484
if (parts.length === 0) return '[' + String(obj) + ']';
8585
return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';
8686
}
87-
else if (typeof obj === 'object' && typeof obj.inspect === 'function') {
87+
if (typeof obj === 'object' && typeof obj.inspect === 'function') {
8888
return obj.inspect();
8989
}
90-
else if (isMap(obj)) {
90+
if (isMap(obj)) {
9191
var parts = [];
9292
mapForEach.call(obj, function (value, key) {
9393
parts.push(inspect(key, obj) + ' => ' + inspect(value, obj));
9494
});
9595
return 'Map (' + mapSize.call(obj) + ') {' + parts.join(', ') + '}';
9696
}
97-
else if (isSet(obj)) {
97+
if (isSet(obj)) {
9898
var parts = [];
9999
setForEach.call(obj, function (value ) {
100100
parts.push(inspect(value, obj));
101101
});
102102
return 'Set (' + setSize.call(obj) + ') {' + parts.join(', ') + '}';
103103
}
104-
else if (typeof obj !== 'object') {
104+
if (typeof obj !== 'object') {
105105
return String(obj);
106106
}
107-
else if (isNumber(obj)) {
107+
if (isNumber(obj)) {
108108
return 'Object(' + Number(obj) + ')';
109109
}
110-
else if (isBoolean(obj)) {
110+
if (isBoolean(obj)) {
111111
return 'Object(' + booleanValueOf.call(obj) + ')';
112112
}
113-
else if (isString(obj)) {
113+
if (isString(obj)) {
114114
return 'Object(' + inspect(String(obj)) + ')';
115115
}
116-
else if (!isDate(obj) && !isRegExp(obj)) {
116+
if (!isDate(obj) && !isRegExp(obj)) {
117117
var xs = [], keys = [];
118118
for (var key in obj) {
119119
if (has(obj, key)) keys.push(key);
@@ -129,7 +129,7 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
129129
if (xs.length === 0) return '{}';
130130
return '{ ' + xs.join(', ') + ' }';
131131
}
132-
else return String(obj);
132+
return String(obj);
133133
};
134134

135135
function quote (s) {

0 commit comments

Comments
 (0)