Comparing version 3.0.0 to 3.0.1
@@ -9,3 +9,3 @@ /** | ||
* @module filesize | ||
* @version 3.0.0 | ||
* @version 3.0.1 | ||
*/ | ||
@@ -43,2 +43,3 @@ ( function ( global ) { | ||
output = descriptor.output !== undefined ? descriptor.output : "string"; | ||
e = descriptor.exponent !== undefined ? descriptor.exponent : -1; | ||
num = Number( arg ); | ||
@@ -65,3 +66,6 @@ neg = ( num < 0 ); | ||
else { | ||
e = Math.floor( Math.log( num ) / Math.log( 1000 ) ); | ||
// Determining the exponent | ||
if ( e === -1 || isNaN( e ) ) { | ||
e = Math.floor( Math.log( num ) / Math.log( 1000 ) ); | ||
} | ||
@@ -122,2 +126,5 @@ // Exceeding supported length, time to reduce & multiply | ||
} | ||
else if ( output === "exponent" ) { | ||
return e; | ||
} | ||
else if ( output === "object" ) { | ||
@@ -124,0 +131,0 @@ return { value: result[ 0 ], suffix: result[ 1 ] }; |
{ | ||
"name": "filesize", | ||
"description": "JavaScript library to generate a human readable String describing the file size", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"homepage": "http://filesizejs.com", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -17,4 +17,7 @@ # filesize.js | ||
### exponent | ||
_***(number)***_ Specifies the SI suffix via exponent, e.g. `2` is `MB` for bytes, default is `-1` | ||
### output | ||
_***(string)***_ Output of function (`array`, `object`, or `string`), default is `string` | ||
_***(string)***_ Output of function (`array`, `exponent`, `object`, or `string`), default is `string` | ||
@@ -44,2 +47,5 @@ ### round | ||
filesize(1, {suffixes: {B: "Б"}}); // "1 Б" | ||
filesize(1024); // "1 kB" | ||
filesize(1024, {exponent: 0}); // "1024 B" | ||
filesize(1024, {output: "exponent"}); // 1 | ||
``` | ||
@@ -46,0 +52,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38324
17
155
57