Home / Function/ cached() — vue Function Reference

cached() — vue Function Reference

Architecture documentation for the cached() function in util.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  36b9e386_0d72_59bb_2717_c0d64e158252["cached()"]
  b7977953_caa1_d867_207c_74cfbf6421e0["util.ts"]
  36b9e386_0d72_59bb_2717_c0d64e158252 -->|defined in| b7977953_caa1_d867_207c_74cfbf6421e0
  33b2b1b8_c260_20f5_bfa9_83feaaadd162["camelize()"]
  33b2b1b8_c260_20f5_bfa9_83feaaadd162 -->|calls| 36b9e386_0d72_59bb_2717_c0d64e158252
  2d425b2f_68b4_cc9a_931d_388dcda5d277["capitalize()"]
  2d425b2f_68b4_cc9a_931d_388dcda5d277 -->|calls| 36b9e386_0d72_59bb_2717_c0d64e158252
  7498a1bb_2f8a_a705_5841_3da557bc9574["hyphenate()"]
  7498a1bb_2f8a_a705_5841_3da557bc9574 -->|calls| 36b9e386_0d72_59bb_2717_c0d64e158252
  style 36b9e386_0d72_59bb_2717_c0d64e158252 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/shared/util.ts lines 169–175

export function cached<R>(fn: (str: string) => R): (sr: string) => R {
  const cache: Record<string, R> = Object.create(null)
  return function cachedFn(str: string) {
    const hit = cache[str]
    return hit || (cache[str] = fn(str))
  }
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does cached() do?
cached() is a function in the vue codebase, defined in src/shared/util.ts.
Where is cached() defined?
cached() is defined in src/shared/util.ts at line 169.
What calls cached()?
cached() is called by 3 function(s): camelize, capitalize, hyphenate.

Analyze Your Own Codebase

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

Try Supermodel Free