Map
Hierarchy
- Map
Constructors
constructor
- new Map(length: number): Map 
- 
Creates a new Sass map. ⚠️ Heads up!The initial keys and values of the map are undefined. They must be set using setKey and setValue before accessing them or passing the map back to Sass. Exampleconst map = new sass.types.Map(2);
 map.setKey(0, new sass.types.String("width"));
 map.setValue(0, new sass.types.Number(300, "px"));
 map.setKey(1, new sass.types.String("height"));
 map.setValue(1, new sass.types.Number(100, "px"));
 map; // (width: 300px, height: 100px)Parameters- 
length: numberThe number of (initially undefined) key/value pairs in the map. 
 Returns Map
- 
Methods
get
- getKey(index: number): LegacyValue 
- 
Returns the key in the key/value pair at index.Example// map is `(width: 300px, height: 100px)`
 map.getKey(0); // width
 map.getKey(1); // heightThrowsErrorifindexis less than 0 or greater than or equal to the number of pairs in this map.Parameters- 
index: numberA (0-based) index of a key/value pair in this map. 
 Returns LegacyValue
- 
get
get
- getValue(index: number): LegacyValue 
- 
Returns the value in the key/value pair at index.Example// map is `(width: 300px, height: 100px)`
 map.getValue(0); // 300px
 map.getValue(1); // 100pxThrowsErrorifindexis less than 0 or greater than or equal to the number of pairs in this map.Parameters- 
index: numberA (0-based) index of a key/value pair in this map. 
 Returns LegacyValue
- 
set
- setKey(index: number, key: LegacyValue): void 
- 
Sets the value in the key/value pair at indextovalue.Example// map is `("light": 200, "medium": 400, "bold": 600)`
 map.setValue(1, new sass.types.String("lighter"));
 map; // ("lighter": 200, "medium": 300, "bold": 600)ThrowsErrorifindexis less than 0 or greater than or equal to the number of pairs in this map.Parameters- 
index: numberA (0-based) index of a key/value pair in this map. 
- 
key: LegacyValue
 Returns void
- 
set
- setValue(index: number, value: LegacyValue): void 
- 
Sets the value in the key/value pair at indextovalue.Example// map is `("light": 200, "medium": 400, "bold": 600)`
 map.setValue(1, new sass.types.Number(300));
 map; // ("light": 200, "medium": 300, "bold": 600)ThrowsErrorifindexis less than 0 or greater than or equal to the number of pairs in this map.Parameters- 
index: numberA (0-based) index of a key/value pair in this map. 
- 
value: LegacyValue
 Returns void
- 
Sass's map type.
⚠️ Heads up!
This map type is represented as a list of key-value pairs rather than a mapping from keys to values. The only way to find the value associated with a given key is to iterate through the map checking for that key. Maps created through this API are still forbidden from having duplicate keys.