Spec-Zone.ru › Sass

Map

Sass's map type.

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.

Hierarchy

  • Map
  • Defined in js-api-doc/legacy/function.d.ts:642
Index

Constructors

constructor

Methods

getKey getLength getValue setKey setValue

Constructors

constructor

  • new Map(length: number): Map
  • Creates a new Sass map.

    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.

    Example

    constmap = newsass.types.Map(2);
    map.setKey(0, newsass.types.String("width"));
    map.setValue(0, newsass.types.Number(300, "px"));
    map.setKey(1, newsass.types.String("height"));
    map.setValue(1, newsass.types.Number(100, "px"));
    map; // (width: 300px, height: 100px)

    Parameters

    • length: number

      The number of (initially undefined) key/value pairs in the map.

    Returns Map

    • Defined in js-api-doc/legacy/function.d.ts:663

Methods

getKey

  • 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); // height

    Throws

    Error if index is less than 0 or greater than or equal to the number of pairs in this map.

    Parameters

    • index: number

      A (0-based) index of a key/value pair in this map.

    Returns LegacyValue

    • Defined in js-api-doc/legacy/function.d.ts:714

getLength

  • getLength(): number
  • Returns the number of key/value pairs in this map.

    Example

    // map is `("light": 200, "medium": 400, "bold": 600)`
    map.getLength(); // 3

    // map is `(width: 300px, height: 100px)`
    map.getLength(); // 2

    Returns number

    • Defined in js-api-doc/legacy/function.d.ts:746

getValue

  • 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); // 100px

    Throws

    Error if index is less than 0 or greater than or equal to the number of pairs in this map.

    Parameters

    • index: number

      A (0-based) index of a key/value pair in this map.

    Returns LegacyValue

    • Defined in js-api-doc/legacy/function.d.ts:680

setKey

  • setKey(index: number, key: LegacyValue): void
  • Sets the value in the key/value pair at index to value.

    Example

    // map is `("light": 200, "medium": 400, "bold": 600)`
    map.setValue(1, newsass.types.String("lighter"));
    map; // ("lighter": 200, "medium": 300, "bold": 600)

    Throws

    Error if index is less than 0 or greater than or equal to the number of pairs in this map.

    Parameters

    • index: number

      A (0-based) index of a key/value pair in this map.

    • key: LegacyValue

    Returns void

    • Defined in js-api-doc/legacy/function.d.ts:731

setValue

  • setValue(index: number, value: LegacyValue): void
  • Sets the value in the key/value pair at index to value.

    Example

    // map is `("light": 200, "medium": 400, "bold": 600)`
    map.setValue(1, newsass.types.Number(300));
    map; // ("light": 200, "medium": 300, "bold": 600)

    Throws

    Error if index is less than 0 or greater than or equal to the number of pairs in this map.

    Parameters

    • index: number

      A (0-based) index of a key/value pair in this map.

    • value: LegacyValue

    Returns void

    • Defined in js-api-doc/legacy/function.d.ts:697
sass
  • Compile
    • AsyncCompiler
    • Compiler
    • CompileResult
    • compile
    • compileAsync
    • compileString
    • compileStringAsync
    • initAsyncCompiler
    • initCompiler
  • Options
    • Options
    • StringOptions
    • OutputStyle
    • StringOptionsWithImporter
    • StringOptionsWithoutImporter
    • Syntax
  • Logger
    • Logger
      • silent
    • Logger
    • SourceLocation
    • SourceSpan
    • LoggerWarnOptions
  • Importer
    • NodePackageImporter
    • FileImporter
    • Importer
    • ImporterResult
  • Custom Function
    • CalculationInterpolation
    • CalculationOperation
    • SassArgumentList
    • SassBoolean
    • SassCalculation
    • SassColor
    • SassFunction
    • SassList
    • SassMap
    • SassMixin
    • SassNumber
    • SassString
    • Value
    • CalculationOperator
    • CalculationValue
    • CustomFunction
    • ListSeparator
    • sassFalse
    • sassNull
    • sassTrue
  • Other
    • Exception
    • CanonicalizeContext
    • Deprecations
    • LegacyFileOptions
    • ChannelName
    • ChannelNameHsl
    • ChannelNameHwb
    • ChannelNameLab
    • ChannelNameLch
    • ChannelNameRgb
    • ChannelNameXyz
    • ColorSpaceHsl
    • ColorSpaceHwb
    • ColorSpaceLab
    • ColorSpaceLch
    • ColorSpaceRgb
    • ColorSpaceXyz
    • GamutMapMethod
    • HueInterpolationMethod
    • KnownColorSpace
    • PolarColorSpace
    • PromiseOr
    • RectangularColorSpace
    • info
  • Legacy
    • types
      • Boolean
      • Color
      • Error
      • List
      • Map
      • Null
      • Number
      • String
    • LegacyException
    • LegacyImporterThis
    • LegacyPluginThis
    • LegacyResult
    • LegacySharedOptions
    • LegacyStringOptions
    • LegacyAsyncFunction
    • LegacyAsyncFunctionDone
    • LegacyAsyncImporter
    • LegacyFunction
    • LegacyImporter
    • LegacyImporterResult
    • LegacyOptions
    • LegacySyncFunction
    • LegacySyncImporter
    • LegacyValue
    • FALSE
    • NULL
    • TRUE
    • render
    • renderSync
  • Messages
    • Version
    • Deprecation
    • DeprecationOrId
    • DeprecationStatus
    • deprecations

© 2006–2025 the Sass team, and numerous contributors
Licensed under the MIT License.
https://sass-lang.com/documentation/js-api/classes/types.Map

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API