list.to()
The list.to()
function returns $list
with elements from the first index to the given $to
index.
// Functions.
@use 'list.nth.function';
// Modules.
@use '../number';
// The `list.to()` function.
@function to($list, $to) {
@return list.nth($list, number.range(0, $to) or $to...);
}
https://github.com/angular-package/sass/blob/main/list/_list.to.function.scss
// Functions.
@use 'list.nth.function';
// Modules.
@use '../math';
// Status: DONE
// The `list.to()` function returns `$list` with elements from the first index to the given `$to` index.
// @param `$list` The list to get the elements from `1` to given `$to`.
// @param `$to` Index of the last element to retrieve from `$list`.
// @return The return value is the list of the elements from `1` to given `$to` index.
@function to($list, $to) {
@return list.nth($list, math.range(0, $to) or $to...);
}
// Examples.
// $-list: ('a', 'b', c, d, 2, 4, 5, (a: 1));
// @debug to(('a',), 1); // ("a",)
// @debug to(('a',), -1); // ("a",)
// @debug to($-list, 1); // ("a",)
// @debug to($-list, -1); // ((a: 1),)
// @debug to($-list, 4); // "a", "b", c, d
// @debug to($-list, 7); // "a", "b", c, d, 2, 4, 5
// @debug to('&' '.' 'a' 'b' 'c', 2); // "&" "."
Parameters
$list
$list
The list to get the elements from 1
to given $to
.
$to
$to
Index of the last element to retrieve from $list
.
Return
The return value is the list of the elements from 1
to given $to
index.
Examples
// Use.
@use 'angular-package/sass/list';
$-list: ('a', 'b', c, d, 2, 4, 5, (a: 1));
// Examples.
@debug list.to(('a',), 1); // ("a",)
@debug list.to(('a',), -1); // ("a",)
@debug list.to($-list, 1); // ("a",)
@debug list.to($-list, -1); // ((a: 1),)
@debug list.to($-list, 4); // "a", "b", c, d
@debug list.to($-list, 7); // "a", "b", c, d, 2, 4, 5
@debug list.to('&' '.' 'a' 'b' 'c', 2); // "&" "."
Last updated
Was this helpful?