Skip to content

API Reference

import {
class Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
} from "@devhaven/unit-conversion";
const
const conversion: Conversion
conversion
= new
new Conversion(config?: ConversionConfig): Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
();
const
const result: InputValue
result
=
const conversion: Conversion
conversion
.
Conversion.value<10>(val: 10): ValueWithFrom<10>
value
(10).
ValueWithFrom<10>.from<"meter">(unit: "meter"): FromUnit<10, "meter">
from
("meter").
FromUnit<10, "meter">.to<"foot">(unit: "foot"): InputValue
to
("foot");
  • Optional
  • Default: 2
  • Number of decimal places to round the conversion result to.
import {
class Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
} from "@devhaven/unit-conversion";
const
const conversion: Conversion
conversion
= new
new Conversion(config?: ConversionConfig): Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
({
ConversionConfig.decimals?: number
decimals
: 4 });
const
const result: InputValue
result
=
const conversion: Conversion
conversion
.
Conversion.value<10>(val: 10): ValueWithFrom<10>
value
(10).
ValueWithFrom<10>.from<"meter">(unit: "meter"): FromUnit<10, "meter">
from
("meter").
FromUnit<10, "meter">.to<"foot">(unit: "foot"): InputValue
to
("foot");
  • Optional
  • Default: false
  • If true, the conversion result will be a floating-point number.
import {
class Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
} from "@devhaven/unit-conversion";
const
const conversion: Conversion
conversion
= new
new Conversion(config?: ConversionConfig): Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
({
ConversionConfig.isFloat?: boolean
isFloat
: true });
const
const result: InputValue
result
=
const conversion: Conversion
conversion
.
Conversion.value<10>(val: 10): ValueWithFrom<10>
value
(10).
ValueWithFrom<10>.from<"meter">(unit: "meter"): FromUnit<10, "meter">
from
("meter").
FromUnit<10, "meter">.to<"foot">(unit: "foot"): InputValue
to
("foot");
  • Optional
  • Default: false
  • If true, the conversion result will include the unit as a string.
import {
class Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
} from "@devhaven/unit-conversion";
const
const conversion: Conversion
conversion
= new
new Conversion(config?: ConversionConfig): Conversion

Represents a utility class for unit conversions.

The Conversion class provides a fluent API for converting values between different units. It allows customization through configuration options passed to the constructor.

@example

const conversion = new Conversion();
const result = conversion.value(5).from('meters').to('feet');

Conversion
({
ConversionConfig.includeUnit?: boolean
includeUnit
: false });
const
const result: InputValue
result
=
const conversion: Conversion
conversion
.
Conversion.value<10>(val: 10): ValueWithFrom<10>
value
(10).
ValueWithFrom<10>.from<"meter">(unit: "meter"): FromUnit<10, "meter">
from
("meter").
FromUnit<10, "meter">.to<"foot">(unit: "foot"): InputValue
to
("foot");