Number
Hierarchy
- Number
Index
Constructors
Methods
Constructors
constructor
- new
Number(value: number, unit?: string): Number -
Example
new sass.types.Number(0.5); // == 0.5
new sass.types.Number(10, "px"); // == 10px
new sass.types.Number(10, "px*px"); // == 10px * 1px
new 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: stringIf 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
-
Methods
get Unit
- get
Unit(): 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
get Value
set Unit
- set
Unit(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
-
set Value
- set
Value(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
-
Sass's number type.