Skip to content
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

Adding exponent to object output, fixes #112 #113

Merged
merged 2 commits into from
Feb 22, 2020
Merged
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

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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"
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)$/,
@@ -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);
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
@@ -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)$/,
@@ -161,7 +161,8 @@
if (output === "object") {
return {
value: result[0],
symbol: result[1]
symbol: result[1],
exponent: e
};
}

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.

1,023 changes: 545 additions & 478 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions 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": "6.0.1",
"version": "6.1.0",
"homepage": "https://filesizejs.com",
"author": "Jason Mulligan <jason.mulligan@avoidwork.com>",
"repository": {
@@ -35,7 +35,7 @@
"grunt-babel": "^8.0.0",
"grunt-cli": "^1.3.2",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-nodeunit": "^2.0.0",
"grunt-contrib-nodeunit": "^2.1.0",
"grunt-contrib-uglify": "^4.0.1",
"grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "^22.0.0"
2 changes: 1 addition & 1 deletion src/filesize.js
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@
}

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

return result.join(spacer);