Home / Function/ formatBytesCompact() — supabase Function Reference

formatBytesCompact() — supabase Function Reference

Architecture documentation for the formatBytesCompact() function in Usage.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  1af9f391_e944_58fa_f58e_74773af03676["formatBytesCompact()"]
  5d050e22_3ef1_5377_1886_45aa975918a9["ChartYFormatterCompactNumber()"]
  5d050e22_3ef1_5377_1886_45aa975918a9 -->|calls| 1af9f391_e944_58fa_f58e_74773af03676
  style 1af9f391_e944_58fa_f58e_74773af03676 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Organization/Usage/Usage.utils.ts lines 81–97

const formatBytesCompact = (bytes: number) => {
  if (bytes === 0 || bytes === undefined) return '0 bytes'

  const k = 1024
  const i = Math.floor(Math.log(bytes) / Math.log(k))

  const unit = sizes[i]

  let dm = 2
  if (['bytes', 'KB', 'MB'].includes(unit)) {
    dm = 0
  } else if (['GB'].includes(unit)) {
    dm = 1
  }

  return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + unit
}

Subdomains

Frequently Asked Questions

What does formatBytesCompact() do?
formatBytesCompact() is a function in the supabase codebase.
What calls formatBytesCompact()?
formatBytesCompact() is called by 1 function(s): ChartYFormatterCompactNumber.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free