UNPKG

unitsnet-js

Version:

A better way to hold unit variables and easily convert to the destination unit

243 lines (242 loc) 9.65 kB
import { BaseUnit, ToStringOptions } from "../base-unit"; /** API DTO represents a Temperature */ export interface TemperatureDto { /** The value of the Temperature */ value: number; /** The specific unit that the Temperature value is representing */ unit: TemperatureUnits; } /** TemperatureUnits enumeration */ export declare enum TemperatureUnits { /** */ Kelvins = "Kelvin", /** */ DegreesCelsius = "DegreeCelsius", /** */ MillidegreesCelsius = "MillidegreeCelsius", /** */ DegreesDelisle = "DegreeDelisle", /** */ DegreesFahrenheit = "DegreeFahrenheit", /** */ DegreesNewton = "DegreeNewton", /** */ DegreesRankine = "DegreeRankine", /** */ DegreesReaumur = "DegreeReaumur", /** */ DegreesRoemer = "DegreeRoemer", /** */ SolarTemperatures = "SolarTemperature" } /** A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. */ export declare class Temperature extends BaseUnit { protected value: number; private kelvinsLazy; private degreescelsiusLazy; private millidegreescelsiusLazy; private degreesdelisleLazy; private degreesfahrenheitLazy; private degreesnewtonLazy; private degreesrankineLazy; private degreesreaumurLazy; private degreesroemerLazy; private solartemperaturesLazy; /** * Create a new Temperature. * @param value The value. * @param fromUnit The ‘Temperature’ unit to create from. * The default unit is Kelvins */ constructor(value: number, fromUnit?: TemperatureUnits); /** * The base value of Temperature is Kelvins. * This accessor used when needs a value for calculations and it's better to use directly the base value */ get BaseValue(): number; /** Gets the default unit used when creating instances of the unit or its DTO */ protected get baseUnit(): TemperatureUnits.Kelvins; /** */ get Kelvins(): number; /** */ get DegreesCelsius(): number; /** */ get MillidegreesCelsius(): number; /** */ get DegreesDelisle(): number; /** */ get DegreesFahrenheit(): number; /** */ get DegreesNewton(): number; /** */ get DegreesRankine(): number; /** */ get DegreesReaumur(): number; /** */ get DegreesRoemer(): number; /** */ get SolarTemperatures(): number; /** * Create a new Temperature instance from a Kelvins * * @param value The unit as Kelvins to create a new Temperature from. * @returns The new Temperature instance. */ static FromKelvins(value: number): Temperature; /** * Create a new Temperature instance from a DegreesCelsius * * @param value The unit as DegreesCelsius to create a new Temperature from. * @returns The new Temperature instance. */ static FromDegreesCelsius(value: number): Temperature; /** * Create a new Temperature instance from a MillidegreesCelsius * * @param value The unit as MillidegreesCelsius to create a new Temperature from. * @returns The new Temperature instance. */ static FromMillidegreesCelsius(value: number): Temperature; /** * Create a new Temperature instance from a DegreesDelisle * * @param value The unit as DegreesDelisle to create a new Temperature from. * @returns The new Temperature instance. */ static FromDegreesDelisle(value: number): Temperature; /** * Create a new Temperature instance from a DegreesFahrenheit * * @param value The unit as DegreesFahrenheit to create a new Temperature from. * @returns The new Temperature instance. */ static FromDegreesFahrenheit(value: number): Temperature; /** * Create a new Temperature instance from a DegreesNewton * * @param value The unit as DegreesNewton to create a new Temperature from. * @returns The new Temperature instance. */ static FromDegreesNewton(value: number): Temperature; /** * Create a new Temperature instance from a DegreesRankine * * @param value The unit as DegreesRankine to create a new Temperature from. * @returns The new Temperature instance. */ static FromDegreesRankine(value: number): Temperature; /** * Create a new Temperature instance from a DegreesReaumur * * @param value The unit as DegreesReaumur to create a new Temperature from. * @returns The new Temperature instance. */ static FromDegreesReaumur(value: number): Temperature; /** * Create a new Temperature instance from a DegreesRoemer * * @param value The unit as DegreesRoemer to create a new Temperature from. * @returns The new Temperature instance. */ static FromDegreesRoemer(value: number): Temperature; /** * Create a new Temperature instance from a SolarTemperatures * * @param value The unit as SolarTemperatures to create a new Temperature from. * @returns The new Temperature instance. */ static FromSolarTemperatures(value: number): Temperature; /** * Gets the base unit enumeration associated with Temperature * @returns The unit enumeration that can be used to interact with this type */ protected static getUnitEnum(): typeof TemperatureUnits; /** * Gets the default unit used when creating instances of the unit or its DTO * @returns The unit enumeration value used as a default parameter in constructor and DTO methods */ protected static getBaseUnit(): TemperatureUnits.Kelvins; /** * Create API DTO represent a Temperature unit. * @param holdInUnit The specific Temperature unit to be used in the unit representation at the DTO */ toDto(holdInUnit?: TemperatureUnits): TemperatureDto; /** * Create a Temperature unit from an API DTO representation. * @param dtoTemperature The Temperature API DTO representation */ static FromDto(dtoTemperature: TemperatureDto): Temperature; /** * Convert Temperature to a specific unit value. * @param toUnit The specific unit to convert to * @returns The value of the specific unit provided. */ convert(toUnit: TemperatureUnits): number; private convertFromBase; private convertToBase; /** * Format the Temperature to string. * Note! the default format for Temperature is Kelvins. * To specify the unit format set the 'unit' parameter. * @param unit The unit to format the Temperature. * @param options The ToString options, it also can be the number of fractional digits to keep that deprecated and moved to the options object. support in number will be dropped in the upcoming versions. * @returns The string format of the Temperature. */ toString(unit?: TemperatureUnits, options?: number | ToStringOptions): string; /** * Get Temperature unit abbreviation. * Note! the default abbreviation for Temperature is Kelvins. * To specify the unit abbreviation set the 'unitAbbreviation' parameter. * @param unitAbbreviation The unit abbreviation of the Temperature. * @returns The abbreviation string of Temperature. */ getUnitAbbreviation(unitAbbreviation?: TemperatureUnits): string; /** * Check if the given Temperature are equals to the current Temperature. * @param temperature The other Temperature. * @returns True if the given Temperature are equal to the current Temperature. */ equals(temperature: Temperature): boolean; /** * Compare the given Temperature against the current Temperature. * @param temperature The other Temperature. * @returns 0 if they are equal, -1 if the current Temperature is less then other, 1 if the current Temperature is greater then other. */ compareTo(temperature: Temperature): number; /** * Add the given Temperature with the current Temperature. * @param temperature The other Temperature. * @returns A new Temperature instance with the results. */ add(temperature: Temperature): Temperature; /** * Subtract the given Temperature with the current Temperature. * @param temperature The other Temperature. * @returns A new Temperature instance with the results. */ subtract(temperature: Temperature): Temperature; /** * Multiply the given Temperature with the current Temperature. * @param temperature The other Temperature. * @returns A new Temperature instance with the results. */ multiply(temperature: Temperature): Temperature; /** * Divide the given Temperature with the current Temperature. * @param temperature The other Temperature. * @returns A new Temperature instance with the results. */ divide(temperature: Temperature): Temperature; /** * Modulo the given Temperature with the current Temperature. * @param temperature The other Temperature. * @returns A new Temperature instance with the results. */ modulo(temperature: Temperature): Temperature; /** * Pow the given Temperature with the current Temperature. * @param temperature The other Temperature. * @returns A new Temperature instance with the results. */ pow(temperature: Temperature): Temperature; }