Sass Map function


Release date:2024-03-01 Update date:2024-03-01 Editor:admin View counts:148

Label:

Sass Map function

Sass Map (mapping) objects are one or more pairs key/value to show.

Sass Map is immutable, so it is processing Map object, a new Map object, not in the original Map object to make changes.

The following table lists the Sass’s Map function:

Function

Description & example

map-get(map, key)

Returns the value corresponding to key in Map. If there is no corresponding key, the null value is returned.

Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-get ($font-sizes, “small”) result: 12px

map-has-key(map, key)

Determine whether map has a corresponding key. Return true if it exists, otherwise return false.

Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-has-key ($font-sizes, “big”) result: false

map-keys(map)

Returns a queue of all the key in the map.

Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-keys ($font-sizes) result: “small”, “normal,”large”

map-merge(map1, map2)

Merge two map to form a new map type, that is, add map2 to the tail of map1

Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) $font-sizes2: (“x-large”: 30px, “xx-large”: 36px) map-merge ($font-sizes, $font-sizes2) result: “small”: 12px, “normal”: 18px, “large”: 24px, “x-large”: 30px, “xx-large”: 36px

map-remove(map, keys...)

Remove keys from map, and multiple key are separated by commas.

Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-remove ($font-sizes, “small”) result: (“normal”: 18px, “large”: 24px) map-remove ($font-sizes, “small”, “large”) result: (“normal”: 18px)

map-values(map)

Returns all the value in map and generates a queue.

Example: $font-sizes: (“small”: 12px, “normal”: 18px, “large”: 24px) map-values ($font-sizes) result: 12px, 18px, 24px

Powered by TorCMS (https://github.com/bukun/TorCMS).