• Set a value in a Map or WeakMap, and return the value.

    Commonly used with constructions like return map.get(key) ?? setMap(map, key, calculateDefault()).

    Type Parameters

    • K

      The type of key accepted by the map

    • V

      The type of value accepted by the map

    Parameters

    • map: {
          set(key: K, val: V): void;
      }
      • set:function
    • key: K
    • val: V

    Returns V