pick.key-type()

The pick.key-type() function returns a copy of $map with values of $types.

// Sass.
@use 'sass:list';
@use 'sass:map';

// The `pick.key-type()` or `map.pick-key-type()` function.
@function key-type($map, $types...) {
  $result: ();
  @each $type in $types {
    @if list.index(
      bool calculation color function list map null number string,
      $type
    )
    {
      @each $key, $value in $map {
        @if type-of($key) ==
          $type or
          (not $type and type-of($type) == type-of($key))
        {
          $result: map.deep-merge(
            $result,
            (
              $key: $value,
            )
          );
        }
      }
    }
  }
  @return $result;
}

Parameters

$map

A map from which keys of values of $types are picked.

$types...

Types of the values to pick from a $map.

Return

The return value is a copy of $map with a values of types associated with $types.

Examples

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

// Examples.

Last updated