pick.key-substring()

The pick.key-substring() function returns a copy of $map with keys of $substrings.

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

// Modules.
@use '../../string';

// The `pick.key-substring()` or `map.pick-key-substring()` function.
@function key-substring($map, $substrings...) {
  $result: ();
  @each $substring in $substrings {
    @if type-of($substring) == string {
      @each $key in map.keys($map) {
        @if type-of($key) == string and string.index($key, $substring) {
          $result: map.deep-merge(
            $result,
            (
              $key: map.get($map, $key),
            )
          );
        }
      }
    }
  }
  @return $result;
}

Parameters

$map

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

$substrings...

Substrings of keys to pick from a $map.

Return

The return value is a copy of $map with keys associated with $substrings.

Examples

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

// Examples.

Last updated