map ()
Creates a list populated with the results of calling a specified function on every item in a source list.
Parameters
$list
- The list from which items will be processed.
- Type
List
$transformer
- The transform function to apply to each item. The first parameter is the current item being processed in the list. The second parameter is the index of the current item being processed in the list. The third parameter is the list being processed. The returned value may be any type.
- Type
Function
$args
- Additional parameters which are provided to transform function.
- Type
ArgList<*>
- Default
()
$separator
- The type of separator to be used by the created list. Must be passed by name.
- Type
space | comma | slash | auto
- Default
auto
$bracketed
- Whether the created list has square brackets or no brackets. Must be passed by name.
- Type
Boolean | auto
- Default
auto
Return Value
List
- A list with each item being the result of the transformer function.
Example
@use 'sass:meta';
@use '@sass-fairy/list';
@function _add-fifty-plus-n($item, $index, $items, $n) {
@return $item + 50 + $n;
}
$list: 32 8 65 79 34 8 13 66 18;
@debug list.map($list, meta.get-function('_add-fifty-plus-n'), 10);
// 92 68 125 139 94 68 73 126 78