Home / Function/ getOrInsertWith() — react Function Reference

getOrInsertWith() — react Function Reference

Architecture documentation for the getOrInsertWith() function in utils.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4663af75_e270_25e3_3415_1230be609d66["getOrInsertWith()"]
  eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"]
  4663af75_e270_25e3_3415_1230be609d66 -->|defined in| eb9d33f9_42c1_205c_93e6_8e1365a31839
  dd08b3af_83bb_70f8_8837_798eff915e39["addImportSpecifier()"]
  dd08b3af_83bb_70f8_8837_798eff915e39 -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  e9305144_35b9_6cfd_0fec_af0783a96987["validateNoUntransformedReferences()"]
  e9305144_35b9_6cfd_0fec_af0783a96987 -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  7ba64864_37b8_333a_82c1_22a93c4b5c66["validateNamespacedImport()"]
  7ba64864_37b8_333a_82c1_22a93c4b5c66 -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  3522f83b_2dff_3c9f_920f_3e428eb62b31["inferEffectDependencies()"]
  3522f83b_2dff_3c9f_920f_3e428eb62b31 -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  86dd37df_aa77_e57f_86b5_809912afc646["cacheApplySignature()"]
  86dd37df_aa77_e57f_86b5_809912afc646 -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  f5d001aa_7d8a_3660_1e73_93f3fa2883da["computeEffectsForSignature()"]
  f5d001aa_7d8a_3660_1e73_93f3fa2883da -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  c4483c48_7e67_41a0_1a7a_c6ca92a55123["reorderBlock()"]
  c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  10535d5e_42c3_cc4d_c710_f6388cf67d53["getOrGenerateFireFunctionBinding()"]
  10535d5e_42c3_cc4d_c710_f6388cf67d53 -->|calls| 4663af75_e270_25e3_3415_1230be609d66
  style 4663af75_e270_25e3_3415_1230be609d66 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Utils/utils.ts lines 59–71

export function getOrInsertWith<U, V>(
  m: Map<U, V>,
  key: U,
  makeDefault: () => V,
): V {
  if (m.has(key)) {
    return m.get(key) as V;
  } else {
    const defaultValue = makeDefault();
    m.set(key, defaultValue);
    return defaultValue;
  }
}

Domain

Subdomains

Frequently Asked Questions

What does getOrInsertWith() do?
getOrInsertWith() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Utils/utils.ts.
Where is getOrInsertWith() defined?
getOrInsertWith() is defined in compiler/packages/babel-plugin-react-compiler/src/Utils/utils.ts at line 59.
What calls getOrInsertWith()?
getOrInsertWith() is called by 8 function(s): addImportSpecifier, cacheApplySignature, computeEffectsForSignature, getOrGenerateFireFunctionBinding, inferEffectDependencies, reorderBlock, validateNamespacedImport, validateNoUntransformedReferences.

Analyze Your Own Codebase

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

Try Supermodel Free