Home / Function/ redactLines() — supabase Function Reference

redactLines() — supabase Function Reference

Architecture documentation for the redactLines() function in CodeSample.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  4d76fb60_46bd_0571_ceeb_d232b92e476e["redactLines()"]
  beb19324_0ee7_c826_cdeb_54c57d864501["rewriteNodes()"]
  beb19324_0ee7_c826_cdeb_54c57d864501 -->|calls| 4d76fb60_46bd_0571_ceeb_d232b92e476e
  b135dfcb_3344_a04b_5125_18abca69f9f7["_createElidedLine()"]
  4d76fb60_46bd_0571_ceeb_d232b92e476e -->|calls| b135dfcb_3344_a04b_5125_18abca69f9f7
  style 4d76fb60_46bd_0571_ceeb_d232b92e476e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/directives/CodeSample.ts lines 390–413

function redactLines(
  content: string,
  lines: [number, number, ...unknown[]][],
  lang: string | null,
  hideElidedLines: boolean = false
) {
  const contentLines = content.split('\n')
  const preservedLines = lines.reduce((acc, [start, end], index, arr) => {
    if (!hideElidedLines && (index !== 0 || start !== 1)) {
      acc.push(_createElidedLine(lang, contentLines, start, end))
    }

    // Start and end are 1-indexed and inclusive
    acc.push(...contentLines.slice(start - 1, end === -1 ? contentLines.length : end))

    if (!hideElidedLines && index === arr.length - 1 && end !== -1 && end !== contentLines.length) {
      acc.push(_createElidedLine(lang, contentLines, start, end))
    }

    return acc
  }, [] as string[])

  return preservedLines.join('\n').trim()
}

Subdomains

Called By

Frequently Asked Questions

What does redactLines() do?
redactLines() is a function in the supabase codebase.
What does redactLines() call?
redactLines() calls 1 function(s): _createElidedLine.
What calls redactLines()?
redactLines() is called by 1 function(s): rewriteNodes.

Analyze Your Own Codebase

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

Try Supermodel Free