dictionary.set()
The dictionary.set()
function sets the $value
under the $key
in a global and/or given $dictionary
.
// Sass.
@use 'sass:meta';
// Modules.
@use '../../map';
// Functions.
@use 'dictionary.is-global.function' as *;
@use 'dictionary.merge.function' as *;
@use 'dictionary.pick.function' as *;
// Variables.
@forward 'dictionary.variables';
@use 'dictionary.variables' as variables;
// The `translator.dictionary-set()` or `dictionary.set()` function.
@function set($key, $value, $dictionary: (), $global: null) {
$dictionary: map.set(
merge(null, pick(null, $dictionary, false), $global),
$key,
if(meta.type-of($value) == list, map.retrieve(pick, $value...), $value)
);
@if is-global($global) {
variables.$dictionary: $dictionary;
}
@return $dictionary;
}
https://github.com/angular-package/sass/blob/main/translator/dictionary/_dictionary.set.function.scss
Parameters
$key
$key
A key under which set $value
.
$value
$value
A value to set under the $key
.
$dictionary: ()
$dictionary: ()
Additional dictionaries along with a global dictionary(if in use) to set $value
under $key
.
The $dictionary
can be provided as a map
, or as a list
where the first element is a dictionary followed by the list of keys to pick(dictionary.pick()
) and is merged into a global dictionary(if in use).
$global: null
$global: null
A bool
value indicates whether to use a global dictionary. Default, null
, then $dictionary-global
is checked.
Return
The return value is a dictionary with updated $value
in the $key
.
Examples
// Use.
@use '@angular-package/sass/translator';
// Examples.
Last updated
Was this helpful?