@@ -76,28 +76,6 @@ const iconWithLabel = (icon, label, testid, iconSize) => {
7676 return flexLayout ( { items : [ iconSvg , text ] , gap : 20 } ) . join ( "" ) ;
7777} ;
7878
79- /**
80- * Retrieves num with suffix k(thousands) precise to given decimal places.
81- *
82- * @param {number } num The number to format.
83- * @param {number= } precision The number of decimal places to include.
84- * @returns {string|number } The formatted number.
85- */
86- const kFormatter = ( num , precision ) => {
87- const abs = Math . abs ( num ) ;
88- const sign = Math . sign ( num ) ;
89-
90- if ( typeof precision === "number" && ! isNaN ( precision ) ) {
91- return ( sign * ( abs / 1000 ) ) . toFixed ( precision ) + "k" ;
92- }
93-
94- if ( abs < 1000 ) {
95- return sign * abs ;
96- }
97-
98- return sign * parseFloat ( ( abs / 1000 ) . toFixed ( 1 ) ) + "k" ;
99- } ;
100-
10179/**
10280 * Returns boolean if value is either "true" or "false" else the value as it is.
10381 *
@@ -399,40 +377,12 @@ const dateDiff = (d1, d2) => {
399377 return Math . round ( diff / ( 1000 * 60 ) ) ;
400378} ;
401379
402- /**
403- * Convert bytes to a human-readable string representation.
404- *
405- * @param {number } bytes The number of bytes to convert.
406- * @returns {string } The human-readable representation of bytes.
407- * @throws {Error } If bytes is negative or too large.
408- */
409- const formatBytes = ( bytes ) => {
410- if ( bytes < 0 ) {
411- throw new Error ( "Bytes must be a non-negative number" ) ;
412- }
413-
414- if ( bytes === 0 ) {
415- return "0 B" ;
416- }
417-
418- const sizes = [ "B" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" ] ;
419- const base = 1024 ;
420- const i = Math . floor ( Math . log ( bytes ) / Math . log ( base ) ) ;
421-
422- if ( i >= sizes . length ) {
423- throw new Error ( "Bytes is too large to convert to a human-readable string" ) ;
424- }
425-
426- return `${ ( bytes / Math . pow ( base , i ) ) . toFixed ( 1 ) } ${ sizes [ i ] } ` ;
427- } ;
428-
429380export {
430381 ERROR_CARD_LENGTH ,
431382 renderError ,
432383 createLanguageNode ,
433384 iconWithLabel ,
434385 encodeHTML ,
435- kFormatter ,
436386 parseBoolean ,
437387 parseArray ,
438388 clampValue ,
@@ -445,5 +395,4 @@ export {
445395 chunkArray ,
446396 parseEmojis ,
447397 dateDiff ,
448- formatBytes ,
449398} ;
0 commit comments