Skip to content

Commit

Permalink
Merge pull request #113 from avoidwork/exponents
Browse files Browse the repository at this point in the history
Adding `exponent` to `object` output, fixes #112
  • Loading branch information
avoidwork authored Feb 22, 2020
2 parents 6eb9744 + 8acef4c commit b66d8c6
Show file tree
Hide file tree
Showing 12 changed files with 568 additions and 499 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- node
- 12
- 10
- 8

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019, Jason Mulligan
Copyright (c) 2020, Jason Mulligan
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ filesize(265318, {base: 10}); // "265.32 kB"
filesize(265318); // "259.1 KB"
filesize(265318, {round: 0}); // "259 KB"
filesize(265318, {output: "array"}); // [259.1, "KB"]
filesize(265318, {output: "object"}); // {value: 259.1, symbol: "KB"}
filesize(265318, {output: "object"}); // {value: 259.1, symbol: "KB", exponent: 1}
filesize(1, {symbols: {B: "Б"}}); // "1 Б"
filesize(1024); // "1 KB"
filesize(1024, {exponent: 0}); // "1024 B"
Expand Down
6 changes: 3 additions & 3 deletions lib/filesize.es6.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* filesize
*
* @copyright 2019 Jason Mulligan <[email protected]>
* @copyright 2020 Jason Mulligan <[email protected]>
* @license BSD-3-Clause
* @version 6.0.1
* @version 6.1.0
*/
(function (global) {
const b = /^(b|B)$/,
Expand Down Expand Up @@ -141,7 +141,7 @@
}

if (output === "object") {
return {value: result[0], symbol: result[1]};
return {value: result[0], symbol: result[1], exponent: e};
}

return result.join(spacer);
Expand Down
10 changes: 5 additions & 5 deletions lib/filesize.es6.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.es6.min.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions lib/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/**
* filesize
*
* @copyright 2019 Jason Mulligan <[email protected]>
* @copyright 2020 Jason Mulligan <[email protected]>
* @license BSD-3-Clause
* @version 6.0.1
* @version 6.1.0
*/
(function (global) {
var b = /^(b|B)$/,
Expand Down Expand Up @@ -161,7 +161,8 @@
if (output === "object") {
return {
value: result[0],
symbol: result[1]
symbol: result[1],
exponent: e
};
}

Expand Down
6 changes: 3 additions & 3 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.

Loading

0 comments on commit b66d8c6

Please sign in to comment.