Spec-Zone.ru › Sass

Number

Sass's number type.

Hierarchy

  • Number
  • Defined in js-api-doc/legacy/function.d.ts:240
Index

Constructors

constructor

Methods

getUnit getValue setUnit setValue

Constructors

constructor

  • new Number(value: number, unit?: string): Number
  • Example

    new sass.types.Number(0.5); // == 0.5new sass.types.Number(10, "px"); // == 10pxnew sass.types.Number(10, "px*px"); // == 10px * 1pxnew sass.types.Number(10, "px/s"); // == math.div(10px, 1s)new sass.types.Number(10, "px*px/s*s"); // == 10px * math.div(math.div(1px, 1s), 1s)

    Parameters

    • value: number

      The numeric value of the number.

    • Optional unit: string

      If passed, the number's unit.

      Complex units can be represented as <unit>*<unit>*.../<unit>*<unit>*..., with numerator units on the left-hand side of the / and denominator units on the right. A number with only numerator units may omit the / and the units after it, and a number with only denominator units may be represented with no units before the /.

    Returns Number

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

Methods

getUnit

  • getUnit(): string
  • Returns a string representation of this number's units. Complex units are returned in the same format that constructor accepts them.

    Example

    // number is `10px`.
    number.getUnit(); // "px"

    // number is `math.div(10px, 1s)`.
    number.getUnit(); // "px/s"

    Returns string

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

getValue

  • getValue(): number
  • Returns the value of the number, ignoring units.

    This means that 96px and 1in will return different values, even though they represent the same length.

    Example

    constnumber = newsass.types.Number(10, "px");
    number.getValue(); // 10

    Returns number

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

setUnit

  • setUnit(unit: string): void
  • Destructively modifies this number by setting its units to unit, independent of its numeric value. Complex units are specified in the same format as constructor.

    Deprecated

    Use constructor instead.

    Parameters

    • unit: string

    Returns void

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

setValue

  • setValue(value: number): void
  • Destructively modifies this number by setting its numeric value to value, independent of its units.

    Deprecated

    Use constructor instead.

    Parameters

    • value: number

    Returns void

    • Defined in js-api-doc/legacy/function.d.ts:286
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.Number

Spec-Zone.ru

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