[**@bondsports/general**](../README.md) • **Docs**

***

[@bondsports/general](../globals.md) / insertToMapArray

# Function: insertToMapArray()

> **insertToMapArray**\<`K`, `V`\>(`map`, `key`, `value`): `void`

Inserts a value into an array associated with a key in a Map.
If the key does not exist, it initializes it with an empty array.

## Type Parameters

• **K** = `string`

The type of the keys in the Map (defaults to string).

• **V** = `any`

The type of the values in the Map (defaults to any).

## Parameters

• **map**: `Map`\<`K`, `V`[]\>

The Map to modify, where K is the key type and V is the value type.

• **key**: `K`

The key under which to store the value.

• **value**: `V`

The value to insert into the array associated with the key.

## Returns

`void`

## Throws

Throws an error if the provided map is not a Map instance.

## Defined in

[utils/array.util.ts:238](https://github.com/Bond-Sports/bondUtils/blob/545f16ceb055481acfd7641d7809c0f252d3a5e6/packages/general/src/utils/array.util.ts#L238)
