Skip to content

Commit

Permalink
Fixing 0 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jan 25, 2017
1 parent 7bc227e commit d957df3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/filesize.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2017 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 3.5.1
* @version 3.5.3
*/
(function (global) {
const b = /^(b|B)$/,
Expand Down Expand Up @@ -60,6 +60,7 @@

// Zero is now a special case because bytes divide by 1
if (num === 0) {
e = 0;
result[0] = 0;
result[1] = unix ? "" : !bits ? "B" : "b";
} else {
Expand Down Expand Up @@ -123,7 +124,7 @@
}

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

return result.join(spacer);
Expand Down
5 changes: 3 additions & 2 deletions lib/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright 2017 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 3.5.1
* @version 3.5.3
*/
(function (global) {
var b = /^(b|B)$/,
Expand Down Expand Up @@ -76,6 +76,7 @@

// Zero is now a special case because bytes divide by 1
if (num === 0) {
e = 0;
result[0] = 0;
result[1] = unix ? "" : !bits ? "B" : "b";
} else {
Expand Down Expand Up @@ -139,7 +140,7 @@
}

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

return result.join(spacer);
Expand Down
4 changes: 2 additions & 2 deletions lib/filesize.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/filesize.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "3.5.2",
"version": "3.5.3",
"homepage": "http://filesizejs.com",
"author": "Jason Mulligan <jason.mulligan@avoidwork.com>",
"repository": {
Expand Down

0 comments on commit d957df3

Please sign in to comment.