UNPKG

unitsnet-js

Version:

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

147 lines (146 loc) 5.46 kB
import { BaseUnit, ToStringOptions } from "../base-unit"; /** API DTO represents a Level */ export interface LevelDto { /** The value of the Level */ value: number; /** The specific unit that the Level value is representing */ unit: LevelUnits; } /** LevelUnits enumeration */ export declare enum LevelUnits { /** */ Decibels = "Decibel", /** */ Nepers = "Neper" } /** Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. */ export declare class Level extends BaseUnit { protected value: number; private decibelsLazy; private nepersLazy; /** * Create a new Level. * @param value The value. * @param fromUnit The ‘Level’ unit to create from. * The default unit is Decibels */ constructor(value: number, fromUnit?: LevelUnits); /** * The base value of Level is Decibels. * 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(): LevelUnits.Decibels; /** */ get Decibels(): number; /** */ get Nepers(): number; /** * Create a new Level instance from a Decibels * * @param value The unit as Decibels to create a new Level from. * @returns The new Level instance. */ static FromDecibels(value: number): Level; /** * Create a new Level instance from a Nepers * * @param value The unit as Nepers to create a new Level from. * @returns The new Level instance. */ static FromNepers(value: number): Level; /** * Gets the base unit enumeration associated with Level * @returns The unit enumeration that can be used to interact with this type */ protected static getUnitEnum(): typeof LevelUnits; /** * 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(): LevelUnits.Decibels; /** * Create API DTO represent a Level unit. * @param holdInUnit The specific Level unit to be used in the unit representation at the DTO */ toDto(holdInUnit?: LevelUnits): LevelDto; /** * Create a Level unit from an API DTO representation. * @param dtoLevel The Level API DTO representation */ static FromDto(dtoLevel: LevelDto): Level; /** * Convert Level to a specific unit value. * @param toUnit The specific unit to convert to * @returns The value of the specific unit provided. */ convert(toUnit: LevelUnits): number; private convertFromBase; private convertToBase; /** * Format the Level to string. * Note! the default format for Level is Decibels. * To specify the unit format set the 'unit' parameter. * @param unit The unit to format the Level. * @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 Level. */ toString(unit?: LevelUnits, options?: number | ToStringOptions): string; /** * Get Level unit abbreviation. * Note! the default abbreviation for Level is Decibels. * To specify the unit abbreviation set the 'unitAbbreviation' parameter. * @param unitAbbreviation The unit abbreviation of the Level. * @returns The abbreviation string of Level. */ getUnitAbbreviation(unitAbbreviation?: LevelUnits): string; /** * Check if the given Level are equals to the current Level. * @param level The other Level. * @returns True if the given Level are equal to the current Level. */ equals(level: Level): boolean; /** * Compare the given Level against the current Level. * @param level The other Level. * @returns 0 if they are equal, -1 if the current Level is less then other, 1 if the current Level is greater then other. */ compareTo(level: Level): number; /** * Add the given Level with the current Level. * @param level The other Level. * @returns A new Level instance with the results. */ add(level: Level): Level; /** * Subtract the given Level with the current Level. * @param level The other Level. * @returns A new Level instance with the results. */ subtract(level: Level): Level; /** * Multiply the given Level with the current Level. * @param level The other Level. * @returns A new Level instance with the results. */ multiply(level: Level): Level; /** * Divide the given Level with the current Level. * @param level The other Level. * @returns A new Level instance with the results. */ divide(level: Level): Level; /** * Modulo the given Level with the current Level. * @param level The other Level. * @returns A new Level instance with the results. */ modulo(level: Level): Level; /** * Pow the given Level with the current Level. * @param level The other Level. * @returns A new Level instance with the results. */ pow(level: Level): Level; }