@@ -8,14 +8,15 @@ import type {
88import { encodePackageName } from '#shared/utils/npm'
99import type { PackageAnalysisResponse } from './usePackageAnalysis'
1010import { isBinaryOnlyPackage } from '#shared/utils/binary-detection'
11+ import { formatBytes } from '~/utils/formatters'
1112import { getDependencyCount } from '~/utils/npm/dependency-count'
1213
1314export interface PackageComparisonData {
1415 package : ComparisonPackage
1516 downloads ?: number
1617 /** Package's own unpacked size (from dist.unpackedSize) */
1718 packageSize ?: number
18- /** Direct dependencies count */
19+ /** Number of direct dependencies */
1920 directDeps : number | null
2021 /** Install size data (fetched lazily) */
2122 installSize ?: {
@@ -365,8 +366,8 @@ function computeFacetValue(
365366 }
366367 }
367368 case 'dependencies' : {
368- if ( data . directDeps == null ) return null
369369 const depCount = data . directDeps
370+ if ( depCount === null ) return null
370371 return {
371372 raw : depCount ,
372373 display : String ( depCount ) ,
@@ -399,12 +400,6 @@ function computeFacetValue(
399400 }
400401}
401402
402- function formatBytes ( bytes : number ) : string {
403- if ( bytes < 1024 ) return `${ bytes } B`
404- if ( bytes < 1024 * 1024 ) return `${ ( bytes / 1024 ) . toFixed ( 1 ) } kB`
405- return `${ ( bytes / ( 1024 * 1024 ) ) . toFixed ( 1 ) } MB`
406- }
407-
408403function isStale ( date : Date ) : boolean {
409404 const now = new Date ( )
410405 const diffMs = now . getTime ( ) - date . getTime ( )
0 commit comments