List
Hierarchy
- List
Index
Constructors
Methods
Constructors
constructor
- new
List(length: number, commaSeparator?: boolean): List -
Creates a new Sass list.
⚠️ Atenção!
The initial values of the list elements are undefined. These elements must be set using setValue before accessing them or passing the list back to Sass.
Example
const list = new sass.types.List(3);
list.setValue(0, new sass.types.Number(10, "px"));
list.setValue(1, new sass.types.Number(15, "px"));
list.setValue(2, new sass.types.Number(32, "px"));
list; // 10px, 15px, 32pxParameters
-
length: number
The number of (initially undefined) elements in the list.
-
Optional
commaSeparator: booleanIf
true
, the list is comma-separated; otherwise, it's space-separated. Defaults totrue
.
Returns List
-
Methods
get Length
get Separator
get Value
- get
Value(index: number): undefined | LegacyValue -
Returns the element at
index
, orundefined
if that value hasn't yet been set.Example
// list is `10px, 15px, 32px`
list.getValue(0); // 10px
list.getValue(2); // 32pxThrows
Error
ifindex
is less than 0 or greater than or equal to the number of elements in this list.Parameters
-
index: number
A (0-based) index into this list.
Returns undefined | LegacyValue
-
set Separator
set Value
- set
Value(index: number, value: LegacyValue): void -
Sets the element at
index
tovalue
.Example
// list is `10px, 15px, 32px`
list.setValue(1, new sass.types.Number(18, "px"));
list; // 10px, 18px, 32pxThrows
Error
ifindex
is less than 0 or greater than or equal to the number of elements in this list.Parameters
-
index: number
A (0-based) index into this list.
-
value: LegacyValue
Returns void
-
Sass's list type.
⚠️ Atenção!
This list type’s methods use 0-based indexing, even though within Sass lists use 1-based indexing. These methods also don’t support using negative numbers to index backwards from the end of the list.