Skip to content

Commit 93f3b70

Browse files
committed
Update usePackageComparison.ts
1 parent ed19aab commit 93f3b70

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

app/composables/usePackageComparison.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import type {
88
import { encodePackageName } from '#shared/utils/npm'
99
import type { PackageAnalysisResponse } from './usePackageAnalysis'
1010
import { isBinaryOnlyPackage } from '#shared/utils/binary-detection'
11+
import { formatBytes } from '~/utils/formatters'
1112
import { getDependencyCount } from '~/utils/npm/dependency-count'
1213

1314
export 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-
408403
function isStale(date: Date): boolean {
409404
const now = new Date()
410405
const diffMs = now.getTime() - date.getTime()

0 commit comments

Comments
 (0)