Download wp-calypso/client/site-profiler/utils/formatting-data.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 372 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/site-profiler/utils/formatting-data.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/site-profiler/utils/formatting-data.ts
-
curl -L -o formatting-data.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/site-profiler/utils/formatting-data.ts
372 Bytes
| export function getFormattedNumber( value: number | string, dec = 2 ) { | |
| return Number( Number( value ?? 0 ).toFixed( dec ) ); | |
| } | |
| export function getFormattedSize( size: number ) { | |
| const i = size === 0 ? 0 : Math.floor( Math.log( size ) / Math.log( 1024 ) ); | |
| return ( | |
| +( size / Math.pow( 1024, i ) ).toFixed( 2 ) * 1 + ' ' + [ 'B', 'kB', 'MB', 'GB', 'TB' ][ i ] | |
| ); | |
| } | |