<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [rc-js-util](./rc-js-util.md) &gt; [mapInitializeGet](./rc-js-util.mapinitializeget_1.md)

## mapInitializeGet() function

Gets the value from a `Map` for a given key, where the value is `undefined` or hasn't been set, the callback's return will be inserted into the `Map` and returned.

**Signature:**

```typescript
export declare function mapInitializeGet<TMapKey extends object, TKey extends TMapKey, TMapValue, TValue extends TMapValue>(map: WeakMap<TMapKey, TMapValue>, key: TKey, getValue: (key: TKey) => TValue): TMapValue;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

map


</td><td>

WeakMap&lt;TMapKey, TMapValue&gt;


</td><td>

The `Map` to search and modify.


</td></tr>
<tr><td>

key


</td><td>

TKey


</td><td>

The key to search for / set in `map`<!-- -->.


</td></tr>
<tr><td>

getValue


</td><td>

(key: TKey) =&gt; TValue


</td><td>

The function to call if a value is not found.


</td></tr>
</tbody></table>
**Returns:**

TMapValue

The value in `map`<!-- -->, otherwise the result of the `getValue`<!-- -->.

## Remarks

See [mapInitializeGet()](./rc-js-util.mapinitializeget.md)<!-- -->.

