Skip to content

Adding exponent to object output, fixes #112 #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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