unitsnet-js
Version:
A better way to hold unit variables and easily convert to the destination unit
135 lines (134 loc) • 5.13 kB
TypeScript
import { BaseUnit, ToStringOptions } from "../base-unit";
/** API DTO represents a Scalar */
export interface ScalarDto {
/** The value of the Scalar */
value: number;
/** The specific unit that the Scalar value is representing */
unit: ScalarUnits;
}
/** ScalarUnits enumeration */
export declare enum ScalarUnits {
/** */
Amount = "Amount"
}
/** A way of representing a number of items. */
export declare class Scalar extends BaseUnit {
protected value: number;
private amountLazy;
/**
* Create a new Scalar.
* @param value The value.
* @param fromUnit The ‘Scalar’ unit to create from.
* The default unit is Amount
*/
constructor(value: number, fromUnit?: ScalarUnits);
/**
* The base value of Scalar is Amount.
* 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(): ScalarUnits.Amount;
/** */
get Amount(): number;
/**
* Create a new Scalar instance from a Amount
*
* @param value The unit as Amount to create a new Scalar from.
* @returns The new Scalar instance.
*/
static FromAmount(value: number): Scalar;
/**
* Gets the base unit enumeration associated with Scalar
* @returns The unit enumeration that can be used to interact with this type
*/
protected static getUnitEnum(): typeof ScalarUnits;
/**
* 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(): ScalarUnits.Amount;
/**
* Create API DTO represent a Scalar unit.
* @param holdInUnit The specific Scalar unit to be used in the unit representation at the DTO
*/
toDto(holdInUnit?: ScalarUnits): ScalarDto;
/**
* Create a Scalar unit from an API DTO representation.
* @param dtoScalar The Scalar API DTO representation
*/
static FromDto(dtoScalar: ScalarDto): Scalar;
/**
* Convert Scalar to a specific unit value.
* @param toUnit The specific unit to convert to
* @returns The value of the specific unit provided.
*/
convert(toUnit: ScalarUnits): number;
private convertFromBase;
private convertToBase;
/**
* Format the Scalar to string.
* Note! the default format for Scalar is Amount.
* To specify the unit format set the 'unit' parameter.
* @param unit The unit to format the Scalar.
* @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 Scalar.
*/
toString(unit?: ScalarUnits, options?: number | ToStringOptions): string;
/**
* Get Scalar unit abbreviation.
* Note! the default abbreviation for Scalar is Amount.
* To specify the unit abbreviation set the 'unitAbbreviation' parameter.
* @param unitAbbreviation The unit abbreviation of the Scalar.
* @returns The abbreviation string of Scalar.
*/
getUnitAbbreviation(unitAbbreviation?: ScalarUnits): string;
/**
* Check if the given Scalar are equals to the current Scalar.
* @param scalar The other Scalar.
* @returns True if the given Scalar are equal to the current Scalar.
*/
equals(scalar: Scalar): boolean;
/**
* Compare the given Scalar against the current Scalar.
* @param scalar The other Scalar.
* @returns 0 if they are equal, -1 if the current Scalar is less then other, 1 if the current Scalar is greater then other.
*/
compareTo(scalar: Scalar): number;
/**
* Add the given Scalar with the current Scalar.
* @param scalar The other Scalar.
* @returns A new Scalar instance with the results.
*/
add(scalar: Scalar): Scalar;
/**
* Subtract the given Scalar with the current Scalar.
* @param scalar The other Scalar.
* @returns A new Scalar instance with the results.
*/
subtract(scalar: Scalar): Scalar;
/**
* Multiply the given Scalar with the current Scalar.
* @param scalar The other Scalar.
* @returns A new Scalar instance with the results.
*/
multiply(scalar: Scalar): Scalar;
/**
* Divide the given Scalar with the current Scalar.
* @param scalar The other Scalar.
* @returns A new Scalar instance with the results.
*/
divide(scalar: Scalar): Scalar;
/**
* Modulo the given Scalar with the current Scalar.
* @param scalar The other Scalar.
* @returns A new Scalar instance with the results.
*/
modulo(scalar: Scalar): Scalar;
/**
* Pow the given Scalar with the current Scalar.
* @param scalar The other Scalar.
* @returns A new Scalar instance with the results.
*/
pow(scalar: Scalar): Scalar;
}