new Units( [options])
Creates a new Units instance.
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Configuration options Properties
|
- Source:
Methods
-
format(d [, unit])
-
Formats a measurement value with appropriate units. Automatically selects the best unit if none specified.
Parameters:
Name Type Argument Description d
number Value to format (in millimeters)
unit
string <optional>
Specific unit to use for formatting
- Source:
Returns:
Formatted measurement with units (e.g., "5.00 mm" or "1.00 m")
- Type
- string
Example
const units = new Units(); units.format(1500); // Returns "1.50 m" units.format(1500, 'mm'); // Returns "1500.00 mm"