Module core/types/SiType

Overview

This module provides SiType enumeration and utilities for working with it.

The SiType enumeration consists of a set of predefined values representing various units of measurement according to the International System of Units (SI).

The module also provides functions for parsing, stringifying, and checking the validity of these values.

Using the SiType Enumeration

To use the SiType enumeration in your code, you will first need to import it from the module that defines it.

You can do this by adding the following line at the top of your file:

import { SiType } from "./fi/hg/core/types/SiType";

Once you have imported the SiType enumeration, you can use the constants it defines in your code. For example, you could use the SiType.KILO constant in a function like this:

function convertToKilometers (distanceInMeters: number): number {
return distanceInMeters / 1000;
}
const translations = {
[SiType.KILO]: "kilometers",
// ...add more translations for other SiType values as needed
};
const distanceInKilometers = convertToKilometers(5000); // 5
console.log(`The distance is ${distanceInKilometers} ${translations[SiType.KILO]}.`); // The distance is 5 kilometers. *

Using the Utility Functions

The module provides three utility functions that you can use to work with SiType values: isSiType, stringifySiType, and parseSiType.

Here's an example of how you might use these functions in your code:

import { isSiType, stringifySiType, parseSiType } from "./path/to/si-type-module";

// Check if a value is a valid SiType
if (isSiType(SiType.MEGA)) {
console.log("This is a valid SiType value.");
} else {
console.log("This is not a valid SiType value.");
}

// Convert an SiType value to a string
const siTypeString = stringifySiType(SiType.MEGA); // "MEGA"

// Parse a value into an SiType
const siTypeValue = parseSiType("mega"); // SiType.MEGA

Index

Enumerations

Functions

Generated using TypeDoc