unitsnet-js
Version:
A better way to hold unit variables and easily convert to the destination unit
495 lines (494 loc) • 23 kB
TypeScript
import { BaseUnit, ToStringOptions } from "../base-unit";
/** API DTO represents a Mass */
export interface MassDto {
/** The value of the Mass */
value: number;
/** The specific unit that the Mass value is representing */
unit: MassUnits;
}
/** MassUnits enumeration */
export declare enum MassUnits {
/** */
Grams = "Gram",
/** The tonne is a unit of mass equal to 1,000 kilograms. It is a non-SI unit accepted for use with SI. It is also referred to as a metric ton in the United States to distinguish it from the non-metric units of the short ton (United States customary units) and the long ton (British imperial units). It is equivalent to approximately 2,204.6 pounds, 1.102 short tons, and 0.984 long tons. */
Tonnes = "Tonne",
/** The short ton is a unit of mass equal to 2,000 pounds (907.18474 kg), that is most commonly used in the United States – known there simply as the ton. */
ShortTons = "ShortTon",
/** Long ton (weight ton or Imperial ton) is a unit of mass equal to 2,240 pounds (1,016 kg) and is the name for the unit called the "ton" in the avoirdupois or Imperial system of measurements that was used in the United Kingdom and several other Commonwealth countries before metrication. */
LongTons = "LongTon",
/** The pound or pound-mass (abbreviations: lb, lbm) is a unit of mass used in the imperial, United States customary and other systems of measurement. A number of different definitions have been used, the most common today being the international avoirdupois pound which is legally defined as exactly 0.45359237 kilograms, and which is divided into 16 avoirdupois ounces. */
Pounds = "Pound",
/** The international avoirdupois ounce (abbreviated oz) is defined as exactly 28.349523125 g under the international yard and pound agreement of 1959, signed by the United States and countries of the Commonwealth of Nations. 16 oz make up an avoirdupois pound. */
Ounces = "Ounce",
/** The slug (abbreviation slug) is a unit of mass that is accelerated by 1 ft/s² when a force of one pound (lbf) is exerted on it. */
Slugs = "Slug",
/** The stone (abbreviation st) is a unit of mass equal to 14 pounds avoirdupois (about 6.35 kilograms) used in Great Britain and Ireland for measuring human body weight. */
Stone = "Stone",
/** The short hundredweight (abbreviation cwt) is a unit of mass equal to 100 pounds in US and Canada. In British English, the short hundredweight is referred to as the "cental". */
ShortHundredweight = "ShortHundredweight",
/** The long or imperial hundredweight (abbreviation cwt) is a unit of mass equal to 112 pounds in US and Canada. */
LongHundredweight = "LongHundredweight",
/** A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams. */
Grains = "Grain",
/** Solar mass is a ratio unit to the mass of the solar system star, the sun. */
SolarMasses = "SolarMass",
/** Earth mass is a ratio unit to the mass of planet Earth. */
EarthMasses = "EarthMass",
/** The Dalton or unified atomic mass unit (abbreviation Da or u) is a unit of mass defined as 1/12 of the mass of an unbound neutral atom of carbon-12 in its nuclear and electronic ground state and at rest. */
Daltons = "Dalton",
/** */
Femtograms = "Femtogram",
/** */
Picograms = "Picogram",
/** */
Nanograms = "Nanogram",
/** */
Micrograms = "Microgram",
/** */
Milligrams = "Milligram",
/** */
Centigrams = "Centigram",
/** */
Decigrams = "Decigram",
/** */
Decagrams = "Decagram",
/** */
Hectograms = "Hectogram",
/** */
Kilograms = "Kilogram",
/** */
Kilotonnes = "Kilotonne",
/** */
Megatonnes = "Megatonne",
/** */
Kilopounds = "Kilopound",
/** */
Megapounds = "Megapound",
/** */
Kilodaltons = "Kilodalton",
/** */
Megadaltons = "Megadalton",
/** */
Gigadaltons = "Gigadalton"
}
/** In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). */
export declare class Mass extends BaseUnit {
protected value: number;
private gramsLazy;
private tonnesLazy;
private shorttonsLazy;
private longtonsLazy;
private poundsLazy;
private ouncesLazy;
private slugsLazy;
private stoneLazy;
private shorthundredweightLazy;
private longhundredweightLazy;
private grainsLazy;
private solarmassesLazy;
private earthmassesLazy;
private daltonsLazy;
private femtogramsLazy;
private picogramsLazy;
private nanogramsLazy;
private microgramsLazy;
private milligramsLazy;
private centigramsLazy;
private decigramsLazy;
private decagramsLazy;
private hectogramsLazy;
private kilogramsLazy;
private kilotonnesLazy;
private megatonnesLazy;
private kilopoundsLazy;
private megapoundsLazy;
private kilodaltonsLazy;
private megadaltonsLazy;
private gigadaltonsLazy;
/**
* Create a new Mass.
* @param value The value.
* @param fromUnit The ‘Mass’ unit to create from.
* The default unit is Kilograms
*/
constructor(value: number, fromUnit?: MassUnits);
/**
* The base value of Mass is Kilograms.
* 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(): MassUnits.Kilograms;
/** */
get Grams(): number;
/** The tonne is a unit of mass equal to 1,000 kilograms. It is a non-SI unit accepted for use with SI. It is also referred to as a metric ton in the United States to distinguish it from the non-metric units of the short ton (United States customary units) and the long ton (British imperial units). It is equivalent to approximately 2,204.6 pounds, 1.102 short tons, and 0.984 long tons. */
get Tonnes(): number;
/** The short ton is a unit of mass equal to 2,000 pounds (907.18474 kg), that is most commonly used in the United States – known there simply as the ton. */
get ShortTons(): number;
/** Long ton (weight ton or Imperial ton) is a unit of mass equal to 2,240 pounds (1,016 kg) and is the name for the unit called the "ton" in the avoirdupois or Imperial system of measurements that was used in the United Kingdom and several other Commonwealth countries before metrication. */
get LongTons(): number;
/** The pound or pound-mass (abbreviations: lb, lbm) is a unit of mass used in the imperial, United States customary and other systems of measurement. A number of different definitions have been used, the most common today being the international avoirdupois pound which is legally defined as exactly 0.45359237 kilograms, and which is divided into 16 avoirdupois ounces. */
get Pounds(): number;
/** The international avoirdupois ounce (abbreviated oz) is defined as exactly 28.349523125 g under the international yard and pound agreement of 1959, signed by the United States and countries of the Commonwealth of Nations. 16 oz make up an avoirdupois pound. */
get Ounces(): number;
/** The slug (abbreviation slug) is a unit of mass that is accelerated by 1 ft/s² when a force of one pound (lbf) is exerted on it. */
get Slugs(): number;
/** The stone (abbreviation st) is a unit of mass equal to 14 pounds avoirdupois (about 6.35 kilograms) used in Great Britain and Ireland for measuring human body weight. */
get Stone(): number;
/** The short hundredweight (abbreviation cwt) is a unit of mass equal to 100 pounds in US and Canada. In British English, the short hundredweight is referred to as the "cental". */
get ShortHundredweight(): number;
/** The long or imperial hundredweight (abbreviation cwt) is a unit of mass equal to 112 pounds in US and Canada. */
get LongHundredweight(): number;
/** A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams. */
get Grains(): number;
/** Solar mass is a ratio unit to the mass of the solar system star, the sun. */
get SolarMasses(): number;
/** Earth mass is a ratio unit to the mass of planet Earth. */
get EarthMasses(): number;
/** The Dalton or unified atomic mass unit (abbreviation Da or u) is a unit of mass defined as 1/12 of the mass of an unbound neutral atom of carbon-12 in its nuclear and electronic ground state and at rest. */
get Daltons(): number;
/** */
get Femtograms(): number;
/** */
get Picograms(): number;
/** */
get Nanograms(): number;
/** */
get Micrograms(): number;
/** */
get Milligrams(): number;
/** */
get Centigrams(): number;
/** */
get Decigrams(): number;
/** */
get Decagrams(): number;
/** */
get Hectograms(): number;
/** */
get Kilograms(): number;
/** */
get Kilotonnes(): number;
/** */
get Megatonnes(): number;
/** */
get Kilopounds(): number;
/** */
get Megapounds(): number;
/** */
get Kilodaltons(): number;
/** */
get Megadaltons(): number;
/** */
get Gigadaltons(): number;
/**
* Create a new Mass instance from a Grams
*
* @param value The unit as Grams to create a new Mass from.
* @returns The new Mass instance.
*/
static FromGrams(value: number): Mass;
/**
* Create a new Mass instance from a Tonnes
* The tonne is a unit of mass equal to 1,000 kilograms. It is a non-SI unit accepted for use with SI. It is also referred to as a metric ton in the United States to distinguish it from the non-metric units of the short ton (United States customary units) and the long ton (British imperial units). It is equivalent to approximately 2,204.6 pounds, 1.102 short tons, and 0.984 long tons.
* @param value The unit as Tonnes to create a new Mass from.
* @returns The new Mass instance.
*/
static FromTonnes(value: number): Mass;
/**
* Create a new Mass instance from a ShortTons
* The short ton is a unit of mass equal to 2,000 pounds (907.18474 kg), that is most commonly used in the United States – known there simply as the ton.
* @param value The unit as ShortTons to create a new Mass from.
* @returns The new Mass instance.
*/
static FromShortTons(value: number): Mass;
/**
* Create a new Mass instance from a LongTons
* Long ton (weight ton or Imperial ton) is a unit of mass equal to 2,240 pounds (1,016 kg) and is the name for the unit called the "ton" in the avoirdupois or Imperial system of measurements that was used in the United Kingdom and several other Commonwealth countries before metrication.
* @param value The unit as LongTons to create a new Mass from.
* @returns The new Mass instance.
*/
static FromLongTons(value: number): Mass;
/**
* Create a new Mass instance from a Pounds
* The pound or pound-mass (abbreviations: lb, lbm) is a unit of mass used in the imperial, United States customary and other systems of measurement. A number of different definitions have been used, the most common today being the international avoirdupois pound which is legally defined as exactly 0.45359237 kilograms, and which is divided into 16 avoirdupois ounces.
* @param value The unit as Pounds to create a new Mass from.
* @returns The new Mass instance.
*/
static FromPounds(value: number): Mass;
/**
* Create a new Mass instance from a Ounces
* The international avoirdupois ounce (abbreviated oz) is defined as exactly 28.349523125 g under the international yard and pound agreement of 1959, signed by the United States and countries of the Commonwealth of Nations. 16 oz make up an avoirdupois pound.
* @param value The unit as Ounces to create a new Mass from.
* @returns The new Mass instance.
*/
static FromOunces(value: number): Mass;
/**
* Create a new Mass instance from a Slugs
* The slug (abbreviation slug) is a unit of mass that is accelerated by 1 ft/s² when a force of one pound (lbf) is exerted on it.
* @param value The unit as Slugs to create a new Mass from.
* @returns The new Mass instance.
*/
static FromSlugs(value: number): Mass;
/**
* Create a new Mass instance from a Stone
* The stone (abbreviation st) is a unit of mass equal to 14 pounds avoirdupois (about 6.35 kilograms) used in Great Britain and Ireland for measuring human body weight.
* @param value The unit as Stone to create a new Mass from.
* @returns The new Mass instance.
*/
static FromStone(value: number): Mass;
/**
* Create a new Mass instance from a ShortHundredweight
* The short hundredweight (abbreviation cwt) is a unit of mass equal to 100 pounds in US and Canada. In British English, the short hundredweight is referred to as the "cental".
* @param value The unit as ShortHundredweight to create a new Mass from.
* @returns The new Mass instance.
*/
static FromShortHundredweight(value: number): Mass;
/**
* Create a new Mass instance from a LongHundredweight
* The long or imperial hundredweight (abbreviation cwt) is a unit of mass equal to 112 pounds in US and Canada.
* @param value The unit as LongHundredweight to create a new Mass from.
* @returns The new Mass instance.
*/
static FromLongHundredweight(value: number): Mass;
/**
* Create a new Mass instance from a Grains
* A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams.
* @param value The unit as Grains to create a new Mass from.
* @returns The new Mass instance.
*/
static FromGrains(value: number): Mass;
/**
* Create a new Mass instance from a SolarMasses
* Solar mass is a ratio unit to the mass of the solar system star, the sun.
* @param value The unit as SolarMasses to create a new Mass from.
* @returns The new Mass instance.
*/
static FromSolarMasses(value: number): Mass;
/**
* Create a new Mass instance from a EarthMasses
* Earth mass is a ratio unit to the mass of planet Earth.
* @param value The unit as EarthMasses to create a new Mass from.
* @returns The new Mass instance.
*/
static FromEarthMasses(value: number): Mass;
/**
* Create a new Mass instance from a Daltons
* The Dalton or unified atomic mass unit (abbreviation Da or u) is a unit of mass defined as 1/12 of the mass of an unbound neutral atom of carbon-12 in its nuclear and electronic ground state and at rest.
* @param value The unit as Daltons to create a new Mass from.
* @returns The new Mass instance.
*/
static FromDaltons(value: number): Mass;
/**
* Create a new Mass instance from a Femtograms
*
* @param value The unit as Femtograms to create a new Mass from.
* @returns The new Mass instance.
*/
static FromFemtograms(value: number): Mass;
/**
* Create a new Mass instance from a Picograms
*
* @param value The unit as Picograms to create a new Mass from.
* @returns The new Mass instance.
*/
static FromPicograms(value: number): Mass;
/**
* Create a new Mass instance from a Nanograms
*
* @param value The unit as Nanograms to create a new Mass from.
* @returns The new Mass instance.
*/
static FromNanograms(value: number): Mass;
/**
* Create a new Mass instance from a Micrograms
*
* @param value The unit as Micrograms to create a new Mass from.
* @returns The new Mass instance.
*/
static FromMicrograms(value: number): Mass;
/**
* Create a new Mass instance from a Milligrams
*
* @param value The unit as Milligrams to create a new Mass from.
* @returns The new Mass instance.
*/
static FromMilligrams(value: number): Mass;
/**
* Create a new Mass instance from a Centigrams
*
* @param value The unit as Centigrams to create a new Mass from.
* @returns The new Mass instance.
*/
static FromCentigrams(value: number): Mass;
/**
* Create a new Mass instance from a Decigrams
*
* @param value The unit as Decigrams to create a new Mass from.
* @returns The new Mass instance.
*/
static FromDecigrams(value: number): Mass;
/**
* Create a new Mass instance from a Decagrams
*
* @param value The unit as Decagrams to create a new Mass from.
* @returns The new Mass instance.
*/
static FromDecagrams(value: number): Mass;
/**
* Create a new Mass instance from a Hectograms
*
* @param value The unit as Hectograms to create a new Mass from.
* @returns The new Mass instance.
*/
static FromHectograms(value: number): Mass;
/**
* Create a new Mass instance from a Kilograms
*
* @param value The unit as Kilograms to create a new Mass from.
* @returns The new Mass instance.
*/
static FromKilograms(value: number): Mass;
/**
* Create a new Mass instance from a Kilotonnes
*
* @param value The unit as Kilotonnes to create a new Mass from.
* @returns The new Mass instance.
*/
static FromKilotonnes(value: number): Mass;
/**
* Create a new Mass instance from a Megatonnes
*
* @param value The unit as Megatonnes to create a new Mass from.
* @returns The new Mass instance.
*/
static FromMegatonnes(value: number): Mass;
/**
* Create a new Mass instance from a Kilopounds
*
* @param value The unit as Kilopounds to create a new Mass from.
* @returns The new Mass instance.
*/
static FromKilopounds(value: number): Mass;
/**
* Create a new Mass instance from a Megapounds
*
* @param value The unit as Megapounds to create a new Mass from.
* @returns The new Mass instance.
*/
static FromMegapounds(value: number): Mass;
/**
* Create a new Mass instance from a Kilodaltons
*
* @param value The unit as Kilodaltons to create a new Mass from.
* @returns The new Mass instance.
*/
static FromKilodaltons(value: number): Mass;
/**
* Create a new Mass instance from a Megadaltons
*
* @param value The unit as Megadaltons to create a new Mass from.
* @returns The new Mass instance.
*/
static FromMegadaltons(value: number): Mass;
/**
* Create a new Mass instance from a Gigadaltons
*
* @param value The unit as Gigadaltons to create a new Mass from.
* @returns The new Mass instance.
*/
static FromGigadaltons(value: number): Mass;
/**
* Gets the base unit enumeration associated with Mass
* @returns The unit enumeration that can be used to interact with this type
*/
protected static getUnitEnum(): typeof MassUnits;
/**
* 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(): MassUnits.Kilograms;
/**
* Create API DTO represent a Mass unit.
* @param holdInUnit The specific Mass unit to be used in the unit representation at the DTO
*/
toDto(holdInUnit?: MassUnits): MassDto;
/**
* Create a Mass unit from an API DTO representation.
* @param dtoMass The Mass API DTO representation
*/
static FromDto(dtoMass: MassDto): Mass;
/**
* Convert Mass to a specific unit value.
* @param toUnit The specific unit to convert to
* @returns The value of the specific unit provided.
*/
convert(toUnit: MassUnits): number;
private convertFromBase;
private convertToBase;
/**
* Format the Mass to string.
* Note! the default format for Mass is Kilograms.
* To specify the unit format set the 'unit' parameter.
* @param unit The unit to format the Mass.
* @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 Mass.
*/
toString(unit?: MassUnits, options?: number | ToStringOptions): string;
/**
* Get Mass unit abbreviation.
* Note! the default abbreviation for Mass is Kilograms.
* To specify the unit abbreviation set the 'unitAbbreviation' parameter.
* @param unitAbbreviation The unit abbreviation of the Mass.
* @returns The abbreviation string of Mass.
*/
getUnitAbbreviation(unitAbbreviation?: MassUnits): string;
/**
* Check if the given Mass are equals to the current Mass.
* @param mass The other Mass.
* @returns True if the given Mass are equal to the current Mass.
*/
equals(mass: Mass): boolean;
/**
* Compare the given Mass against the current Mass.
* @param mass The other Mass.
* @returns 0 if they are equal, -1 if the current Mass is less then other, 1 if the current Mass is greater then other.
*/
compareTo(mass: Mass): number;
/**
* Add the given Mass with the current Mass.
* @param mass The other Mass.
* @returns A new Mass instance with the results.
*/
add(mass: Mass): Mass;
/**
* Subtract the given Mass with the current Mass.
* @param mass The other Mass.
* @returns A new Mass instance with the results.
*/
subtract(mass: Mass): Mass;
/**
* Multiply the given Mass with the current Mass.
* @param mass The other Mass.
* @returns A new Mass instance with the results.
*/
multiply(mass: Mass): Mass;
/**
* Divide the given Mass with the current Mass.
* @param mass The other Mass.
* @returns A new Mass instance with the results.
*/
divide(mass: Mass): Mass;
/**
* Modulo the given Mass with the current Mass.
* @param mass The other Mass.
* @returns A new Mass instance with the results.
*/
modulo(mass: Mass): Mass;
/**
* Pow the given Mass with the current Mass.
* @param mass The other Mass.
* @returns A new Mass instance with the results.
*/
pow(mass: Mass): Mass;
}