Просмотр исходного кода

Workflow: Improved report-size readability (#29327)

* Workflow: Improved report-size readability.

* no message

* no message
mrdoob 1 год назад
Родитель
Сommit
4476f5d61a
2 измененных файлов с 3 добавлено и 3 удалено
  1. 1 1
      test/treeshake/utils/format-size.js
  2. 2 2
      test/treeshake/utils/formatBytes.js

+ 1 - 1
test/treeshake/utils/format-size.js

@@ -2,6 +2,6 @@
 import { formatBytes } from './formatBytes.js';
 
 const n = Number( process.argv[ 2 ] );
-const formatted = formatBytes( n );
+const formatted = formatBytes( n, 2, false );
 
 console.log( formatted );

+ 2 - 2
test/treeshake/utils/formatBytes.js

@@ -1,4 +1,4 @@
-export function formatBytes( bytes, decimals = 1 ) {
+export function formatBytes( bytes, decimals = 1, units = true ) {
 
 	if ( bytes === 0 ) return '0 B';
 
@@ -8,6 +8,6 @@ export function formatBytes( bytes, decimals = 1 ) {
 
 	const i = Math.floor( Math.log( bytes ) / Math.log( k ) );
 
-	return parseFloat( ( bytes / Math.pow( k, i ) ).toFixed( dm ) ) + ' ' + sizes[ i ];
+	return parseFloat( ( bytes / Math.pow( k, i ) ).toFixed( dm ) ) + ( units ? ' ' + sizes[ i ] : '' );
 
 }

粤ICP备19079148号