// Fetch value from key in map // ------------------------------------------------------------------------------- // @dependence `map-fetche()` // ------------------------------------------------------------------------------- // @param $i [map] : map // @param $n [list] : keys // ------------------------------------------------------------------------------- // @return fetched value | false @function map-fetch($map, $keys) { $key: nth($keys, 1); $length: length($keys); $value: map-get($map, $key); // check if value equals null (meaning the @param was incorrect and the map doesn't exist) @if $value == null { @warn "Invalid arguments padded to function: `map-fetch(#{$map}, #{$keys})`"; @return false; } @else { @if $length > 1 { $rest: (); @for $i from 2 through $length { $rest: append($rest, nth($keys, $i)) } @return map-fetch($value, $rest); } @else { @return $value; } } }