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...);
}

Parameters

$list

The list to get the elements from 1 to given $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