// Sass.
@use 'sass:list';
// Status: DONE
// The `list.join()` returns a new list containing the elements of `$list1` followed by the elements of `$list2`.
// Function handles `$delimiter` functionality.
// @param `$list1` The list to join elements of `$list2`.
// @param `$list2` The list to be joined into `$list1`.
// @param `$separator` Comma, space, or slash separator used between the elements of the list. Default, `auto`.
// @param `$bracketed` If `true` then returned list is between the square brackets.
// @param `$delimiter` The delimiter is the character added as an element between each element in the returned list.
// @return The return value is a new list containing the elements of `$list1` followed by the elements of `$list2`.
@function join(
$list1,
$list2,
$separator: auto,
$bracketed: auto,
$delimiter: null
) {
@if $delimiter {
$result: list.join((), (), $separator, $bracketed);
@each $value in list.join($list1, $list2, $separator) {
$result: if(
list.length($result) > 0,
list.append($result, $delimiter, $separator),
$result
);
$result: list.append($result, $value, $separator);
}
@return $result;
}
@return list.join($list1, $list2, $separator, $bracketed);
}
// Examples.
// modified join
// @debug join((a: a b c), d e f); // a (a b c), d, e, f
// @debug join(d e f, (a: a b c)); // d e f (a (a b c))
// @debug join((a: a b c), (a: a b c)); // a (a b c), a (a b c)
// @debug join(a b c, d e f, $delimiter: '-'); // a "-" b "-" c "-" d "-" e "-" f
// @debug join((a: a b c), d e f, $delimiter: '-'); // (a (a b c)) "-" d "-" e "-" f
// @debug join((a: a b c), d e f, comma, true, '-'); // [a (a b c), "-", d, "-", e, "-", f]