# map.deep-merge-key()

The `map.deep-merge-key()` function merges [`$map`](#usdmap) with retrieved values from [`$keys`](#usdkeys...) of this [`$map`](#usdmap). The properties under [`$keys`](#usdkeys...) are removed.

{% code lineNumbers="true" %}

```scss
// Sass.
@use 'sass:map';

// Functions.
@use 'map.get.function' as *;

// The `map.deep-merge-key()` function.
@function deep-merge-key($map, $keys...) {
  @each $key in $keys {
    $map: map.deep-remove(map.deep-merge($map, get($map, $key, ())), $key...);
  }
  @return $map;
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/map/_map.deep-merge-key.function.scss>" %}

### Parameters

#### `$map`

A map to merge with retrieved values from [`$keys`](#usdkeys...) of this map.

#### `$keys...`

The keys to get the values to merge with [`$map`](#usdmap).

### Return

The return value is a map merged with the values retrieved from [`$keys`](#usdkeys...).

## Examples

```scss
// Use.
@use '@angular-package/sass/map';

// Examples.
$example: (
  "name": first name,
  "age": 25,
  "Helvetica": (
    "weights": (
      "regular": 400,
      "medium": 500,
      "bold": 700
    ),
    "size": (
      "regular": small,
      "medium": big,
      "high": extra big
    )
  )
);

// key of string
@debug map.deep-merge-key((a: 1, b: 2, key: (c: 3, d: 5)), key); // (a: 1, b: 2, c: 3, d: 5)

// nested key
@debug map.deep-merge-key($example, ("Helvetica", "size")); // ("name": first name, "age": 25, "Helvetica": ("weights": ("regular": 400, "medium": 500, "bold": 700)), "regular": small, "medium": big, "high": extra big)
@debug map.deep-merge-key($example, ("Helvetica", "weights")); // ("name": first name, "age": 25, "Helvetica": ("size": ("regular": small, "medium": big, "high": extra big)), "regular": 400, "medium": 500, "bold": 700)
@debug map.deep-merge-key($example, ("Helvetica", "weights"), ("Helvetica", "size")); // ("name": first name, "age": 25, "Helvetica": (), "regular": small, "medium": big, "bold": 700, "high": extra big)
@debug map.deep-merge-key($example, ("Helvetica", "size"), ("Helvetica", "weights")); // ("name": first name, "age": 25, "Helvetica": (), "regular": 400, "medium": 500, "high": extra big, "bold": 700)

// key of comma separated list
@debug map.deep-merge-key((a: 1, b: 2, (key, key1): (c: 3, d: 5)), ((key, key1), )); // (a: 1, b: 2, c: 3, d: 5)

// key of space separated list
@debug map.deep-merge-key((a: 1, b: 2, key key1: (c: 3, d: 5)), (key key1, )); // (a: 1, b: 2, c: 3, d: 5)

// key
@debug map.deep-merge-key((a: 1, b: 2, key key1: (c: 3, d: 5)), (key key1, )); // (a: 1, b: 2, c: 3, d: 5)

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.angular-package.dev/sass/map/map.deep-merge-key.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
