File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,8 +16,13 @@ const formatBytes = (bytes: number): string => {
1616 Math . floor ( Math . log ( bytes ) / Math . log ( 1024 ) ) ,
1717 byteUnits . length - 1
1818 ) ;
19+
1920 const unit = byteUnits [ order ] ;
2021
22+ if ( ! unit ) {
23+ return '???' ;
24+ }
25+
2126 const formatter = new Intl . NumberFormat ( undefined , {
2227 notation : 'compact' ,
2328 style : 'unit' ,
@@ -32,12 +37,17 @@ const formatByteSpeed = (bytesPerSecond: number): string => {
3237 Math . floor ( Math . log ( bytesPerSecond ) / Math . log ( 1024 ) ) ,
3338 byteUnits . length - 1
3439 ) ;
35- const unit = `${ byteUnits [ order ] } -per-second` ;
40+
41+ const unit = byteUnits [ order ] ;
42+
43+ if ( ! unit ) {
44+ return '???' ;
45+ }
3646
3747 const formatter = new Intl . NumberFormat ( undefined , {
3848 notation : 'compact' ,
3949 style : 'unit' ,
40- unit,
50+ unit : ` ${ unit } -per-second` ,
4151 maximumFractionDigits : 1 ,
4252 } ) ;
4353 return formatter . format ( bytesPerSecond / Math . pow ( 1024 , order ) ) ;
You can’t perform that action at this time.
0 commit comments