// Functions.
@use 'map.get.function' as *;
@use 'map.pick.function' as *;
// The `map.retrieve()` function.
@function retrieve($method, $map, $key, $fallback: null) {
@return if(
$method == get,
get($map, $key, $fallback),
if($method == pick, pick($map, $key...), $map or $fallback)
);
}
// Use.
@use '@angular-package/sass/map';
// Examples.
$-dictionary-example: (
general: (word: słowo, (wrapper, wrap): owijka, (technology, technologia): tech, color: c),
class: (prefix: class-prefix, separator: class-separator, suffix: class-suffix, calendars: (calendar: cal), labels: (label: lab)),
prefix: spectre,
border: b,
color: c,
separator: '-',
suffix: end,
outline: o,
var: (prefix: var-prefix, suffix: var-suffix)
);
@debug map.retrieve(get, $-dictionary-example, general); // (word: słowo, (wrapper, wrap): owijka, (technology, technologia): tech, color: c)
@debug map.retrieve(pick, $-dictionary-example, ((class, calendars),)); // (calendars: (calendar: cal))
@debug map.retrieve(pick, $-dictionary-example, (general, (class, calendars))); // (general: (word: słowo, (wrapper, wrap): owijka, (technology, technologia): tech, color: c), calendars: (calendar: cal))
// input list
@debug map.retrieve(pick $-dictionary-example ((class, calendars),)...); // (calendars: (calendar: cal))
// null
@debug map.retrieve(get, $-dictionary-example, test); // null
@debug map.retrieve(pick, $-dictionary-example, test); // (test: null)