@@ -46,38 +46,38 @@ export function formatResourceUnit(
4646 const infix = withoutSpace ? '' : ' ' ;
4747
4848 if ( unit && prefixMap [ unit ] ) {
49- const value = ( amount / prefixMap [ unit ] ) . toFixed ( fixed ) ;
49+ const value = Number ( ( amount / prefixMap [ unit ] ) . toFixed ( fixed ) ) ;
5050 return {
51- string : `${ value } ${ infix } ${ unit } ` ,
51+ string : `${ value . toString ( ) } ${ infix } ${ unit } ` ,
5252 unit : unit ,
53- value : Number ( value ) ,
53+ value : value ,
5454 } ;
5555 }
5656
57- const coreValue = preciseRound ( amount , 2 ) . toFixed ( fixed ) ;
57+ const coreValue = Number ( preciseRound ( amount , 2 ) . toFixed ( fixed ) ) ;
5858
5959 let output = {
60- string : `${ coreValue } ${ infix } ${ unit } ` ,
60+ string : `${ coreValue . toString ( ) } ${ infix } ${ unit } ` ,
6161 unit : unit ,
62- value : Number ( coreValue ) ,
62+ value : coreValue ,
6363 } ;
6464
6565 Object . entries ( prefixMap ) . forEach ( ( [ prefix , power ] ) => {
6666 const tmpValue = amount / power ;
6767 if ( tmpValue >= 1 ) {
68- const value = preciseRound ( tmpValue , 2 ) . toFixed ( fixed ) ;
68+ const value = Number ( preciseRound ( tmpValue , 2 ) . toFixed ( fixed ) ) ;
6969 output = {
70- string : `${ value } ${ infix } ${ prefix } ${ unit } ` ,
70+ string : `${ value . toString ( ) } ${ infix } ${ prefix } ${ unit } ` ,
7171 unit : unit ,
72- value : Number ( value ) ,
72+ value : value ,
7373 } ;
7474 }
7575 } ) ;
7676
7777 return output ;
7878}
7979
80- export function bytesToHumanReadable ( bytes , { fixed = 0 , unit = '' } = { } ) {
80+ export function bytesToHumanReadable ( bytes , { fixed = 1 , unit = '' } = { } ) {
8181 return formatResourceUnit ( bytes , true , { withoutSpace : true , fixed, unit } ) ;
8282}
8383
0 commit comments