Skip to content

Commit a4448cd

Browse files
committed
Removing unneeded nesting of conditionals
1 parent 4fd4373 commit a4448cd

6 files changed

+25
-19
lines changed

lib/filesize.es6.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @license BSD-3 <https://raw.github.com/avoidwork/filesize.js/master/LICENSE>
77
* @link http://filesizejs.com
88
* @module filesize
9-
* @version 3.1.1
9+
* @version 3.1.2
1010
*/
1111
( global ) => {
1212
const bit = /b$/;
@@ -121,15 +121,16 @@ let filesize = ( arg, descriptor={} ) => {
121121
if ( output === "array" ) {
122122
return result;
123123
}
124-
else if ( output === "exponent" ) {
124+
125+
if ( output === "exponent" ) {
125126
return e;
126127
}
127-
else if ( output === "object" ) {
128+
129+
if ( output === "object" ) {
128130
return { value: result[ 0 ], suffix: result[ 1 ] };
129131
}
130-
else {
131-
return result.join( spacer );
132-
}
132+
133+
return result.join( spacer );
133134
}
134135

135136
// CommonJS, AMD, script tag

lib/filesize.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @license BSD-3 <https://raw.github.com/avoidwork/filesize.js/master/LICENSE>
99
* @link http://filesizejs.com
1010
* @module filesize
11-
* @version 3.1.1
11+
* @version 3.1.2
1212
*/
1313
(function (global) {
1414
var bit = /b$/;
@@ -130,13 +130,17 @@
130130
// Returning Array, Object, or String (default)
131131
if (output === "array") {
132132
return result;
133-
} else if (output === "exponent") {
133+
}
134+
135+
if (output === "exponent") {
134136
return e;
135-
} else if (output === "object") {
137+
}
138+
139+
if (output === "object") {
136140
return { value: result[0], suffix: result[1] };
137-
} else {
138-
return result.join(spacer);
139141
}
142+
143+
return result.join(spacer);
140144
};
141145

142146
// CommonJS, AMD, script tag

lib/filesize.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/filesize.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "filesize",
33
"description": "JavaScript library to generate a human readable String describing the file size",
4-
"version": "3.1.1",
4+
"version": "3.1.2",
55
"homepage": "http://filesizejs.com",
66
"author": {
77
"name": "Jason Mulligan",

src/filesize.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@ let filesize = ( arg, descriptor={} ) => {
104104
if ( output === "array" ) {
105105
return result;
106106
}
107-
else if ( output === "exponent" ) {
107+
108+
if ( output === "exponent" ) {
108109
return e;
109110
}
110-
else if ( output === "object" ) {
111+
112+
if ( output === "object" ) {
111113
return { value: result[ 0 ], suffix: result[ 1 ] };
112114
}
113-
else {
114-
return result.join( spacer );
115-
}
115+
116+
return result.join( spacer );
116117
}

0 commit comments

Comments
 (0)