Home / Class/ DualWeakMap Class — vite Architecture

DualWeakMap Class — vite Architecture

Architecture documentation for the DualWeakMap class in mixedModuleGraph.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  83f6432a_baf6_310d_3956_9a91f53f9990["DualWeakMap"]
  cd2f5017_5d73_e10a_7c43_22b962517f0c["mixedModuleGraph.ts"]
  83f6432a_baf6_310d_3956_9a91f53f9990 -->|defined in| cd2f5017_5d73_e10a_7c43_22b962517f0c
  d1f8b612_857c_d18a_b763_92f90bf93d2b["get()"]
  83f6432a_baf6_310d_3956_9a91f53f9990 -->|method| d1f8b612_857c_d18a_b763_92f90bf93d2b
  57bd050c_f162_f6af_9491_3a9b3bcd5ca2["set()"]
  83f6432a_baf6_310d_3956_9a91f53f9990 -->|method| 57bd050c_f162_f6af_9491_3a9b3bcd5ca2

Relationship Graph

Source Code

packages/vite/src/node/server/mixedModuleGraph.ts lines 520–540

class DualWeakMap<K1 extends WeakKey, K2 extends WeakKey, V> {
  private map = new WeakMap<K1 | object, WeakMap<K2 | object, V>>()
  private undefinedKey = {}

  get(key1: K1 | undefined, key2: K2 | undefined): V | undefined {
    const k1 = key1 ?? this.undefinedKey
    const k2 = key2 ?? this.undefinedKey
    return this.map.get(k1)?.get(k2)
  }

  set(key1: K1 | undefined, key2: K2 | undefined, value: V): void {
    const k1 = key1 ?? this.undefinedKey
    const k2 = key2 ?? this.undefinedKey
    if (!this.map.has(k1)) {
      this.map.set(k1, new Map<K2, V>())
    }

    const m = this.map.get(k1)!
    m.set(k2, value)
  }
}

Domain

Frequently Asked Questions

What is the DualWeakMap class?
DualWeakMap is a class in the vite codebase, defined in packages/vite/src/node/server/mixedModuleGraph.ts.
Where is DualWeakMap defined?
DualWeakMap is defined in packages/vite/src/node/server/mixedModuleGraph.ts at line 520.

Analyze Your Own Codebase

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

Try Supermodel Free