Home / Function/ deepFilterRec() — supabase Function Reference

deepFilterRec() — supabase Function Reference

Architecture documentation for the deepFilterRec() function in helpers.fn.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  a31dc3a9_2cda_bb58_7cbc_5f9391c9aabd["deepFilterRec()"]
  3208b6de_e89a_68cd_31fb_acee932136dc["genClientSdkSectionTree()"]
  3208b6de_e89a_68cd_31fb_acee932136dc -->|calls| a31dc3a9_2cda_bb58_7cbc_5f9391c9aabd
  cc06bdf5_979a_d1e8_fed7_bc8f4fe68c7c["genCliSectionTree()"]
  cc06bdf5_979a_d1e8_fed7_bc8f4fe68c7c -->|calls| a31dc3a9_2cda_bb58_7cbc_5f9391c9aabd
  cd24f6d3_9b20_b4e9_4699_9b8057e1f1f5["genApiSectionTree()"]
  cd24f6d3_9b20_b4e9_4699_9b8057e1f1f5 -->|calls| a31dc3a9_2cda_bb58_7cbc_5f9391c9aabd
  b4ff4c86_43e8_1e69_1acd_bb3653aa9f41["genSelfHostedSectionTree()"]
  b4ff4c86_43e8_1e69_1acd_bb3653aa9f41 -->|calls| a31dc3a9_2cda_bb58_7cbc_5f9391c9aabd
  style a31dc3a9_2cda_bb58_7cbc_5f9391c9aabd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/helpers.fn.ts lines 8–27

export function deepFilterRec<T extends object>(
  arr: Array<T>,
  recKey: string,
  filterFn: (item: T) => boolean
): Array<T> {
  return arr.reduce((acc, elem) => {
    if (!filterFn(elem)) return acc

    if (recKey in elem && elem[recKey as keyof T]) {
      const newSubitems = deepFilterRec(elem[recKey as keyof T] as Array<T>, recKey, filterFn)
      const newElem = { ...elem, [recKey]: newSubitems }

      if (newSubitems.length > 0 || filterFn(elem)) acc.push(newElem)
    } else {
      acc.push(elem)
    }

    return acc
  }, [] as Array<T>)
}

Subdomains

Frequently Asked Questions

What does deepFilterRec() do?
deepFilterRec() is a function in the supabase codebase.
What calls deepFilterRec()?
deepFilterRec() is called by 4 function(s): genApiSectionTree, genCliSectionTree, genClientSdkSectionTree, genSelfHostedSectionTree.

Analyze Your Own Codebase

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

Try Supermodel Free