Skip to main content
Version: 1.1.2

Quantity

A number representing a quantity of a given unit.

Syntax

object {
  value,
  unit?,
  per?,
  times?
}

Properties

  • value: number | string | Decimal
    • Scalar value
  • unit?: UnitType
    • Units the quantity is measured in
  • per?: UnitType
    • Optional "per" denominator unit
  • times?: UnitType
    • Optional "times" denominator unit

Example

const cldr = framework.get('en');
let qty: Quantity = { value: '123.57399', unit: 'meter-per-second' };
log(cldr.Units.formatQuantity(qty, { length: 'narrow' }));

qty = { value: '17.9887', unit: 'terabit', per: 'minute' };
log(cldr.Units.formatQuantity(qty));
log(cldr.Units.formatQuantity(qty, { length: 'narrow' }));

qty = { value: '30.7899', unit: 'kilogram', per: 'lux' };
log(cldr.Units.formatQuantity(qty));

qty = { value: '1', unit: 'foot', 'times': 'pound' };
log(cldr.Units.formatQuantity(qty));

qty = { value: '5', unit: 'newton', times: 'meter' };
log(cldr.Units.formatQuantity(qty));
123.574m/s
17.989 terabits per minute
17.989Tb/min
30.79 kilograms per lux
1 foot⋅pound
5 newton⋅meters

References