For the complete documentation index, see llms.txt. This page is also available as Markdown.
map.remove()
The map.remove() function with unified map.remove() and deep-remove() returns $map without $keys.
Modified by adding deep remove on key as comma-separated list. This way of providing key is consistent with a map.set() and map.get() functions.
// Sass.@use'sass:list';@use'sass:map';@use'sass:meta';// The `map.remove()` function.@functionremove($map,$keys...){@each$keyin$keys{$map:if(meta.type-of($key)==listandlist.separator($key)==comma,map.deep-remove($map,$key...),map.remove($map,$key));}@return$map;}
// Sass.
@use 'sass:list';
@use 'sass:map';
@use 'sass:meta';
// Functions.
@use '../list/list.append.function' as *;
// Status: DONE
// The `map.remove()` function with unified `map.remove()` and `deep-remove()` returns a copy `$map` without `$keys`.
// ? Modified by adding deep remove on key as comma-separated list. This way of providing key is consistent with a `map.set()` and `map.get()` functions.
// @param `$map` A map to remove `$keys` from.
// @param `$key` Required to key remove from `$map`.
// @arbitrary `$keys...` Multiple keys to remove from `$map`. If key is a comma-separated list then `map.deep-remove()` function is used, otherwise `map.remove()`.
// @return The return value is a copy of `$map` without any values associated with `$keys`.
@function remove($map, $key, $keys...) {
@each $key in append((), $key, comma, $keys...) {
$map: if(
meta.type-of($key) == list and list.separator($key) == comma,
map.deep-remove($map, $key...),
map.remove($map, $key)
);
}
@return $map;
}
// Examples.
// $-fonts: (
// "Helvetica": (
// "weights": (
// "regular": 400,
// "medium": 500,
// "bold": 700
// )
// ),
// "regular": 400,
// "medium": 500,
// "bold": 700
// );
// key - default feature `map.remove()` and `deep-remove()`.
// @debug remove($-fonts, regular, (Helvetica, weights, medium)); // ("Helvetica": ("weights": ("regular": 400, "bold": 700)), "medium": 500, "bold": 700)