Skip to content

Commit d957df3

Browse files
committed
Fixing 0 bytes
1 parent 7bc227e commit d957df3

7 files changed

+14
-10
lines changed

lib/filesize.es6.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @copyright 2017 Jason Mulligan <[email protected]>
55
* @license BSD-3-Clause
6-
* @version 3.5.1
6+
* @version 3.5.3
77
*/
88
(function (global) {
99
const b = /^(b|B)$/,
@@ -60,6 +60,7 @@
6060

6161
// Zero is now a special case because bytes divide by 1
6262
if (num === 0) {
63+
e = 0;
6364
result[0] = 0;
6465
result[1] = unix ? "" : !bits ? "B" : "b";
6566
} else {
@@ -123,7 +124,7 @@
123124
}
124125

125126
if (full) {
126-
result[1] = fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] > 1 ? "s" : "");
127+
result[1] = fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s");
127128
}
128129

129130
return result.join(spacer);

lib/filesize.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @copyright 2017 Jason Mulligan <[email protected]>
77
* @license BSD-3-Clause
8-
* @version 3.5.1
8+
* @version 3.5.3
99
*/
1010
(function (global) {
1111
var b = /^(b|B)$/,
@@ -76,6 +76,7 @@
7676

7777
// Zero is now a special case because bytes divide by 1
7878
if (num === 0) {
79+
e = 0;
7980
result[0] = 0;
8081
result[1] = unix ? "" : !bits ? "B" : "b";
8182
} else {
@@ -139,7 +140,7 @@
139140
}
140141

141142
if (full) {
142-
result[1] = fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] > 1 ? "s" : "");
143+
result[1] = fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s");
143144
}
144145

145146
return result.join(spacer);

lib/filesize.min.js

+2-2
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.5.2",
4+
"version": "3.5.3",
55
"homepage": "http://filesizejs.com",
66
"author": "Jason Mulligan <[email protected]>",
77
"repository": {

0 commit comments

Comments
 (0)