UNPKG

unitsnet-js

Version:

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

1,034 lines 72.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Energy = exports.EnergyUnits = void 0; const base_unit_1 = require("../base-unit"); /** EnergyUnits enumeration */ var EnergyUnits; (function (EnergyUnits) { /** */ EnergyUnits["Joules"] = "Joule"; /** */ EnergyUnits["Calories"] = "Calorie"; /** */ EnergyUnits["BritishThermalUnits"] = "BritishThermalUnit"; /** In physics, an electronvolt (symbol eV, also written electron-volt and electron volt) is the measure of an amount of kinetic energy gained by a single electron accelerating from rest through an electric potential difference of one volt in vacuum. When used as a unit of energy, the numerical value of 1 eV in joules (symbol J) is equivalent to the numerical value of the charge of an electron in coulombs (symbol C). Under the 2019 redefinition of the SI base units, this sets 1 eV equal to the exact value 1.602176634×10−19 J. */ EnergyUnits["ElectronVolts"] = "ElectronVolt"; /** A pound-foot (lb⋅ft), abbreviated from pound-force foot (lbf · ft), is a unit of torque representing one pound of force acting at a perpendicular distance of one foot from a pivot point. Conversely one foot pound-force (ft · lbf) is the moment about an axis that applies one pound-force at a radius of one foot. */ EnergyUnits["FootPounds"] = "FootPound"; /** The erg is a unit of energy equal to 10−7 joules (100 nJ). It originated in the Centimetre–gram–second system of units (CGS). It has the symbol erg. The erg is not an SI unit. Its name is derived from ergon (ἔργον), a Greek word meaning 'work' or 'task'. */ EnergyUnits["Ergs"] = "Erg"; /** */ EnergyUnits["WattHours"] = "WattHour"; /** */ EnergyUnits["WattDays"] = "WattDay"; /** The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. */ EnergyUnits["ThermsEc"] = "ThermEc"; /** The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. */ EnergyUnits["ThermsUs"] = "ThermUs"; /** The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. */ EnergyUnits["ThermsImperial"] = "ThermImperial"; /** A horsepower-hour (symbol: hp⋅h) is an outdated unit of energy, not used in the International System of Units. The unit represents an amount of work a horse is supposed capable of delivering during an hour (1 horsepower integrated over a time interval of an hour). */ EnergyUnits["HorsepowerHours"] = "HorsepowerHour"; /** */ EnergyUnits["Nanojoules"] = "Nanojoule"; /** */ EnergyUnits["Microjoules"] = "Microjoule"; /** */ EnergyUnits["Millijoules"] = "Millijoule"; /** */ EnergyUnits["Kilojoules"] = "Kilojoule"; /** */ EnergyUnits["Megajoules"] = "Megajoule"; /** */ EnergyUnits["Gigajoules"] = "Gigajoule"; /** */ EnergyUnits["Terajoules"] = "Terajoule"; /** */ EnergyUnits["Petajoules"] = "Petajoule"; /** */ EnergyUnits["Kilocalories"] = "Kilocalorie"; /** */ EnergyUnits["Megacalories"] = "Megacalorie"; /** */ EnergyUnits["KilobritishThermalUnits"] = "KilobritishThermalUnit"; /** */ EnergyUnits["MegabritishThermalUnits"] = "MegabritishThermalUnit"; /** */ EnergyUnits["GigabritishThermalUnits"] = "GigabritishThermalUnit"; /** */ EnergyUnits["KiloelectronVolts"] = "KiloelectronVolt"; /** */ EnergyUnits["MegaelectronVolts"] = "MegaelectronVolt"; /** */ EnergyUnits["GigaelectronVolts"] = "GigaelectronVolt"; /** */ EnergyUnits["TeraelectronVolts"] = "TeraelectronVolt"; /** */ EnergyUnits["KilowattHours"] = "KilowattHour"; /** */ EnergyUnits["MegawattHours"] = "MegawattHour"; /** */ EnergyUnits["GigawattHours"] = "GigawattHour"; /** */ EnergyUnits["TerawattHours"] = "TerawattHour"; /** */ EnergyUnits["KilowattDays"] = "KilowattDay"; /** */ EnergyUnits["MegawattDays"] = "MegawattDay"; /** */ EnergyUnits["GigawattDays"] = "GigawattDay"; /** */ EnergyUnits["TerawattDays"] = "TerawattDay"; /** */ EnergyUnits["DecathermsEc"] = "DecathermEc"; /** */ EnergyUnits["DecathermsUs"] = "DecathermUs"; /** */ EnergyUnits["DecathermsImperial"] = "DecathermImperial"; })(EnergyUnits = exports.EnergyUnits || (exports.EnergyUnits = {})); /** The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. */ class Energy extends base_unit_1.BaseUnit { /** * Create a new Energy. * @param value The value. * @param fromUnit The ‘Energy’ unit to create from. * The default unit is Joules */ constructor(value, fromUnit = EnergyUnits.Joules) { super(); this.joulesLazy = null; this.caloriesLazy = null; this.britishthermalunitsLazy = null; this.electronvoltsLazy = null; this.footpoundsLazy = null; this.ergsLazy = null; this.watthoursLazy = null; this.wattdaysLazy = null; this.thermsecLazy = null; this.thermsusLazy = null; this.thermsimperialLazy = null; this.horsepowerhoursLazy = null; this.nanojoulesLazy = null; this.microjoulesLazy = null; this.millijoulesLazy = null; this.kilojoulesLazy = null; this.megajoulesLazy = null; this.gigajoulesLazy = null; this.terajoulesLazy = null; this.petajoulesLazy = null; this.kilocaloriesLazy = null; this.megacaloriesLazy = null; this.kilobritishthermalunitsLazy = null; this.megabritishthermalunitsLazy = null; this.gigabritishthermalunitsLazy = null; this.kiloelectronvoltsLazy = null; this.megaelectronvoltsLazy = null; this.gigaelectronvoltsLazy = null; this.teraelectronvoltsLazy = null; this.kilowatthoursLazy = null; this.megawatthoursLazy = null; this.gigawatthoursLazy = null; this.terawatthoursLazy = null; this.kilowattdaysLazy = null; this.megawattdaysLazy = null; this.gigawattdaysLazy = null; this.terawattdaysLazy = null; this.decathermsecLazy = null; this.decathermsusLazy = null; this.decathermsimperialLazy = null; if (value === undefined || value === null || Number.isNaN(value)) { throw new TypeError('invalid unit value ‘' + value + '’'); } this.value = this.convertToBase(value, fromUnit); } /** * The base value of Energy is Joules. * This accessor used when needs a value for calculations and it's better to use directly the base value */ get BaseValue() { return this.value; } /** Gets the default unit used when creating instances of the unit or its DTO */ get baseUnit() { return EnergyUnits.Joules; } /** */ get Joules() { if (this.joulesLazy !== null) { return this.joulesLazy; } return this.joulesLazy = this.convertFromBase(EnergyUnits.Joules); } /** */ get Calories() { if (this.caloriesLazy !== null) { return this.caloriesLazy; } return this.caloriesLazy = this.convertFromBase(EnergyUnits.Calories); } /** */ get BritishThermalUnits() { if (this.britishthermalunitsLazy !== null) { return this.britishthermalunitsLazy; } return this.britishthermalunitsLazy = this.convertFromBase(EnergyUnits.BritishThermalUnits); } /** In physics, an electronvolt (symbol eV, also written electron-volt and electron volt) is the measure of an amount of kinetic energy gained by a single electron accelerating from rest through an electric potential difference of one volt in vacuum. When used as a unit of energy, the numerical value of 1 eV in joules (symbol J) is equivalent to the numerical value of the charge of an electron in coulombs (symbol C). Under the 2019 redefinition of the SI base units, this sets 1 eV equal to the exact value 1.602176634×10−19 J. */ get ElectronVolts() { if (this.electronvoltsLazy !== null) { return this.electronvoltsLazy; } return this.electronvoltsLazy = this.convertFromBase(EnergyUnits.ElectronVolts); } /** A pound-foot (lb⋅ft), abbreviated from pound-force foot (lbf · ft), is a unit of torque representing one pound of force acting at a perpendicular distance of one foot from a pivot point. Conversely one foot pound-force (ft · lbf) is the moment about an axis that applies one pound-force at a radius of one foot. */ get FootPounds() { if (this.footpoundsLazy !== null) { return this.footpoundsLazy; } return this.footpoundsLazy = this.convertFromBase(EnergyUnits.FootPounds); } /** The erg is a unit of energy equal to 10−7 joules (100 nJ). It originated in the Centimetre–gram–second system of units (CGS). It has the symbol erg. The erg is not an SI unit. Its name is derived from ergon (ἔργον), a Greek word meaning 'work' or 'task'. */ get Ergs() { if (this.ergsLazy !== null) { return this.ergsLazy; } return this.ergsLazy = this.convertFromBase(EnergyUnits.Ergs); } /** */ get WattHours() { if (this.watthoursLazy !== null) { return this.watthoursLazy; } return this.watthoursLazy = this.convertFromBase(EnergyUnits.WattHours); } /** */ get WattDays() { if (this.wattdaysLazy !== null) { return this.wattdaysLazy; } return this.wattdaysLazy = this.convertFromBase(EnergyUnits.WattDays); } /** The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. */ get ThermsEc() { if (this.thermsecLazy !== null) { return this.thermsecLazy; } return this.thermsecLazy = this.convertFromBase(EnergyUnits.ThermsEc); } /** The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. */ get ThermsUs() { if (this.thermsusLazy !== null) { return this.thermsusLazy; } return this.thermsusLazy = this.convertFromBase(EnergyUnits.ThermsUs); } /** The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. */ get ThermsImperial() { if (this.thermsimperialLazy !== null) { return this.thermsimperialLazy; } return this.thermsimperialLazy = this.convertFromBase(EnergyUnits.ThermsImperial); } /** A horsepower-hour (symbol: hp⋅h) is an outdated unit of energy, not used in the International System of Units. The unit represents an amount of work a horse is supposed capable of delivering during an hour (1 horsepower integrated over a time interval of an hour). */ get HorsepowerHours() { if (this.horsepowerhoursLazy !== null) { return this.horsepowerhoursLazy; } return this.horsepowerhoursLazy = this.convertFromBase(EnergyUnits.HorsepowerHours); } /** */ get Nanojoules() { if (this.nanojoulesLazy !== null) { return this.nanojoulesLazy; } return this.nanojoulesLazy = this.convertFromBase(EnergyUnits.Nanojoules); } /** */ get Microjoules() { if (this.microjoulesLazy !== null) { return this.microjoulesLazy; } return this.microjoulesLazy = this.convertFromBase(EnergyUnits.Microjoules); } /** */ get Millijoules() { if (this.millijoulesLazy !== null) { return this.millijoulesLazy; } return this.millijoulesLazy = this.convertFromBase(EnergyUnits.Millijoules); } /** */ get Kilojoules() { if (this.kilojoulesLazy !== null) { return this.kilojoulesLazy; } return this.kilojoulesLazy = this.convertFromBase(EnergyUnits.Kilojoules); } /** */ get Megajoules() { if (this.megajoulesLazy !== null) { return this.megajoulesLazy; } return this.megajoulesLazy = this.convertFromBase(EnergyUnits.Megajoules); } /** */ get Gigajoules() { if (this.gigajoulesLazy !== null) { return this.gigajoulesLazy; } return this.gigajoulesLazy = this.convertFromBase(EnergyUnits.Gigajoules); } /** */ get Terajoules() { if (this.terajoulesLazy !== null) { return this.terajoulesLazy; } return this.terajoulesLazy = this.convertFromBase(EnergyUnits.Terajoules); } /** */ get Petajoules() { if (this.petajoulesLazy !== null) { return this.petajoulesLazy; } return this.petajoulesLazy = this.convertFromBase(EnergyUnits.Petajoules); } /** */ get Kilocalories() { if (this.kilocaloriesLazy !== null) { return this.kilocaloriesLazy; } return this.kilocaloriesLazy = this.convertFromBase(EnergyUnits.Kilocalories); } /** */ get Megacalories() { if (this.megacaloriesLazy !== null) { return this.megacaloriesLazy; } return this.megacaloriesLazy = this.convertFromBase(EnergyUnits.Megacalories); } /** */ get KilobritishThermalUnits() { if (this.kilobritishthermalunitsLazy !== null) { return this.kilobritishthermalunitsLazy; } return this.kilobritishthermalunitsLazy = this.convertFromBase(EnergyUnits.KilobritishThermalUnits); } /** */ get MegabritishThermalUnits() { if (this.megabritishthermalunitsLazy !== null) { return this.megabritishthermalunitsLazy; } return this.megabritishthermalunitsLazy = this.convertFromBase(EnergyUnits.MegabritishThermalUnits); } /** */ get GigabritishThermalUnits() { if (this.gigabritishthermalunitsLazy !== null) { return this.gigabritishthermalunitsLazy; } return this.gigabritishthermalunitsLazy = this.convertFromBase(EnergyUnits.GigabritishThermalUnits); } /** */ get KiloelectronVolts() { if (this.kiloelectronvoltsLazy !== null) { return this.kiloelectronvoltsLazy; } return this.kiloelectronvoltsLazy = this.convertFromBase(EnergyUnits.KiloelectronVolts); } /** */ get MegaelectronVolts() { if (this.megaelectronvoltsLazy !== null) { return this.megaelectronvoltsLazy; } return this.megaelectronvoltsLazy = this.convertFromBase(EnergyUnits.MegaelectronVolts); } /** */ get GigaelectronVolts() { if (this.gigaelectronvoltsLazy !== null) { return this.gigaelectronvoltsLazy; } return this.gigaelectronvoltsLazy = this.convertFromBase(EnergyUnits.GigaelectronVolts); } /** */ get TeraelectronVolts() { if (this.teraelectronvoltsLazy !== null) { return this.teraelectronvoltsLazy; } return this.teraelectronvoltsLazy = this.convertFromBase(EnergyUnits.TeraelectronVolts); } /** */ get KilowattHours() { if (this.kilowatthoursLazy !== null) { return this.kilowatthoursLazy; } return this.kilowatthoursLazy = this.convertFromBase(EnergyUnits.KilowattHours); } /** */ get MegawattHours() { if (this.megawatthoursLazy !== null) { return this.megawatthoursLazy; } return this.megawatthoursLazy = this.convertFromBase(EnergyUnits.MegawattHours); } /** */ get GigawattHours() { if (this.gigawatthoursLazy !== null) { return this.gigawatthoursLazy; } return this.gigawatthoursLazy = this.convertFromBase(EnergyUnits.GigawattHours); } /** */ get TerawattHours() { if (this.terawatthoursLazy !== null) { return this.terawatthoursLazy; } return this.terawatthoursLazy = this.convertFromBase(EnergyUnits.TerawattHours); } /** */ get KilowattDays() { if (this.kilowattdaysLazy !== null) { return this.kilowattdaysLazy; } return this.kilowattdaysLazy = this.convertFromBase(EnergyUnits.KilowattDays); } /** */ get MegawattDays() { if (this.megawattdaysLazy !== null) { return this.megawattdaysLazy; } return this.megawattdaysLazy = this.convertFromBase(EnergyUnits.MegawattDays); } /** */ get GigawattDays() { if (this.gigawattdaysLazy !== null) { return this.gigawattdaysLazy; } return this.gigawattdaysLazy = this.convertFromBase(EnergyUnits.GigawattDays); } /** */ get TerawattDays() { if (this.terawattdaysLazy !== null) { return this.terawattdaysLazy; } return this.terawattdaysLazy = this.convertFromBase(EnergyUnits.TerawattDays); } /** */ get DecathermsEc() { if (this.decathermsecLazy !== null) { return this.decathermsecLazy; } return this.decathermsecLazy = this.convertFromBase(EnergyUnits.DecathermsEc); } /** */ get DecathermsUs() { if (this.decathermsusLazy !== null) { return this.decathermsusLazy; } return this.decathermsusLazy = this.convertFromBase(EnergyUnits.DecathermsUs); } /** */ get DecathermsImperial() { if (this.decathermsimperialLazy !== null) { return this.decathermsimperialLazy; } return this.decathermsimperialLazy = this.convertFromBase(EnergyUnits.DecathermsImperial); } /** * Create a new Energy instance from a Joules * * @param value The unit as Joules to create a new Energy from. * @returns The new Energy instance. */ static FromJoules(value) { return new Energy(value, EnergyUnits.Joules); } /** * Create a new Energy instance from a Calories * * @param value The unit as Calories to create a new Energy from. * @returns The new Energy instance. */ static FromCalories(value) { return new Energy(value, EnergyUnits.Calories); } /** * Create a new Energy instance from a BritishThermalUnits * * @param value The unit as BritishThermalUnits to create a new Energy from. * @returns The new Energy instance. */ static FromBritishThermalUnits(value) { return new Energy(value, EnergyUnits.BritishThermalUnits); } /** * Create a new Energy instance from a ElectronVolts * In physics, an electronvolt (symbol eV, also written electron-volt and electron volt) is the measure of an amount of kinetic energy gained by a single electron accelerating from rest through an electric potential difference of one volt in vacuum. When used as a unit of energy, the numerical value of 1 eV in joules (symbol J) is equivalent to the numerical value of the charge of an electron in coulombs (symbol C). Under the 2019 redefinition of the SI base units, this sets 1 eV equal to the exact value 1.602176634×10−19 J. * @param value The unit as ElectronVolts to create a new Energy from. * @returns The new Energy instance. */ static FromElectronVolts(value) { return new Energy(value, EnergyUnits.ElectronVolts); } /** * Create a new Energy instance from a FootPounds * A pound-foot (lb⋅ft), abbreviated from pound-force foot (lbf · ft), is a unit of torque representing one pound of force acting at a perpendicular distance of one foot from a pivot point. Conversely one foot pound-force (ft · lbf) is the moment about an axis that applies one pound-force at a radius of one foot. * @param value The unit as FootPounds to create a new Energy from. * @returns The new Energy instance. */ static FromFootPounds(value) { return new Energy(value, EnergyUnits.FootPounds); } /** * Create a new Energy instance from a Ergs * The erg is a unit of energy equal to 10−7 joules (100 nJ). It originated in the Centimetre–gram–second system of units (CGS). It has the symbol erg. The erg is not an SI unit. Its name is derived from ergon (ἔργον), a Greek word meaning 'work' or 'task'. * @param value The unit as Ergs to create a new Energy from. * @returns The new Energy instance. */ static FromErgs(value) { return new Energy(value, EnergyUnits.Ergs); } /** * Create a new Energy instance from a WattHours * * @param value The unit as WattHours to create a new Energy from. * @returns The new Energy instance. */ static FromWattHours(value) { return new Energy(value, EnergyUnits.WattHours); } /** * Create a new Energy instance from a WattDays * * @param value The unit as WattDays to create a new Energy from. * @returns The new Energy instance. */ static FromWattDays(value) { return new Energy(value, EnergyUnits.WattDays); } /** * Create a new Energy instance from a ThermsEc * The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. * @param value The unit as ThermsEc to create a new Energy from. * @returns The new Energy instance. */ static FromThermsEc(value) { return new Energy(value, EnergyUnits.ThermsEc); } /** * Create a new Energy instance from a ThermsUs * The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. * @param value The unit as ThermsUs to create a new Energy from. * @returns The new Energy instance. */ static FromThermsUs(value) { return new Energy(value, EnergyUnits.ThermsUs); } /** * Create a new Energy instance from a ThermsImperial * The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory. * @param value The unit as ThermsImperial to create a new Energy from. * @returns The new Energy instance. */ static FromThermsImperial(value) { return new Energy(value, EnergyUnits.ThermsImperial); } /** * Create a new Energy instance from a HorsepowerHours * A horsepower-hour (symbol: hp⋅h) is an outdated unit of energy, not used in the International System of Units. The unit represents an amount of work a horse is supposed capable of delivering during an hour (1 horsepower integrated over a time interval of an hour). * @param value The unit as HorsepowerHours to create a new Energy from. * @returns The new Energy instance. */ static FromHorsepowerHours(value) { return new Energy(value, EnergyUnits.HorsepowerHours); } /** * Create a new Energy instance from a Nanojoules * * @param value The unit as Nanojoules to create a new Energy from. * @returns The new Energy instance. */ static FromNanojoules(value) { return new Energy(value, EnergyUnits.Nanojoules); } /** * Create a new Energy instance from a Microjoules * * @param value The unit as Microjoules to create a new Energy from. * @returns The new Energy instance. */ static FromMicrojoules(value) { return new Energy(value, EnergyUnits.Microjoules); } /** * Create a new Energy instance from a Millijoules * * @param value The unit as Millijoules to create a new Energy from. * @returns The new Energy instance. */ static FromMillijoules(value) { return new Energy(value, EnergyUnits.Millijoules); } /** * Create a new Energy instance from a Kilojoules * * @param value The unit as Kilojoules to create a new Energy from. * @returns The new Energy instance. */ static FromKilojoules(value) { return new Energy(value, EnergyUnits.Kilojoules); } /** * Create a new Energy instance from a Megajoules * * @param value The unit as Megajoules to create a new Energy from. * @returns The new Energy instance. */ static FromMegajoules(value) { return new Energy(value, EnergyUnits.Megajoules); } /** * Create a new Energy instance from a Gigajoules * * @param value The unit as Gigajoules to create a new Energy from. * @returns The new Energy instance. */ static FromGigajoules(value) { return new Energy(value, EnergyUnits.Gigajoules); } /** * Create a new Energy instance from a Terajoules * * @param value The unit as Terajoules to create a new Energy from. * @returns The new Energy instance. */ static FromTerajoules(value) { return new Energy(value, EnergyUnits.Terajoules); } /** * Create a new Energy instance from a Petajoules * * @param value The unit as Petajoules to create a new Energy from. * @returns The new Energy instance. */ static FromPetajoules(value) { return new Energy(value, EnergyUnits.Petajoules); } /** * Create a new Energy instance from a Kilocalories * * @param value The unit as Kilocalories to create a new Energy from. * @returns The new Energy instance. */ static FromKilocalories(value) { return new Energy(value, EnergyUnits.Kilocalories); } /** * Create a new Energy instance from a Megacalories * * @param value The unit as Megacalories to create a new Energy from. * @returns The new Energy instance. */ static FromMegacalories(value) { return new Energy(value, EnergyUnits.Megacalories); } /** * Create a new Energy instance from a KilobritishThermalUnits * * @param value The unit as KilobritishThermalUnits to create a new Energy from. * @returns The new Energy instance. */ static FromKilobritishThermalUnits(value) { return new Energy(value, EnergyUnits.KilobritishThermalUnits); } /** * Create a new Energy instance from a MegabritishThermalUnits * * @param value The unit as MegabritishThermalUnits to create a new Energy from. * @returns The new Energy instance. */ static FromMegabritishThermalUnits(value) { return new Energy(value, EnergyUnits.MegabritishThermalUnits); } /** * Create a new Energy instance from a GigabritishThermalUnits * * @param value The unit as GigabritishThermalUnits to create a new Energy from. * @returns The new Energy instance. */ static FromGigabritishThermalUnits(value) { return new Energy(value, EnergyUnits.GigabritishThermalUnits); } /** * Create a new Energy instance from a KiloelectronVolts * * @param value The unit as KiloelectronVolts to create a new Energy from. * @returns The new Energy instance. */ static FromKiloelectronVolts(value) { return new Energy(value, EnergyUnits.KiloelectronVolts); } /** * Create a new Energy instance from a MegaelectronVolts * * @param value The unit as MegaelectronVolts to create a new Energy from. * @returns The new Energy instance. */ static FromMegaelectronVolts(value) { return new Energy(value, EnergyUnits.MegaelectronVolts); } /** * Create a new Energy instance from a GigaelectronVolts * * @param value The unit as GigaelectronVolts to create a new Energy from. * @returns The new Energy instance. */ static FromGigaelectronVolts(value) { return new Energy(value, EnergyUnits.GigaelectronVolts); } /** * Create a new Energy instance from a TeraelectronVolts * * @param value The unit as TeraelectronVolts to create a new Energy from. * @returns The new Energy instance. */ static FromTeraelectronVolts(value) { return new Energy(value, EnergyUnits.TeraelectronVolts); } /** * Create a new Energy instance from a KilowattHours * * @param value The unit as KilowattHours to create a new Energy from. * @returns The new Energy instance. */ static FromKilowattHours(value) { return new Energy(value, EnergyUnits.KilowattHours); } /** * Create a new Energy instance from a MegawattHours * * @param value The unit as MegawattHours to create a new Energy from. * @returns The new Energy instance. */ static FromMegawattHours(value) { return new Energy(value, EnergyUnits.MegawattHours); } /** * Create a new Energy instance from a GigawattHours * * @param value The unit as GigawattHours to create a new Energy from. * @returns The new Energy instance. */ static FromGigawattHours(value) { return new Energy(value, EnergyUnits.GigawattHours); } /** * Create a new Energy instance from a TerawattHours * * @param value The unit as TerawattHours to create a new Energy from. * @returns The new Energy instance. */ static FromTerawattHours(value) { return new Energy(value, EnergyUnits.TerawattHours); } /** * Create a new Energy instance from a KilowattDays * * @param value The unit as KilowattDays to create a new Energy from. * @returns The new Energy instance. */ static FromKilowattDays(value) { return new Energy(value, EnergyUnits.KilowattDays); } /** * Create a new Energy instance from a MegawattDays * * @param value The unit as MegawattDays to create a new Energy from. * @returns The new Energy instance. */ static FromMegawattDays(value) { return new Energy(value, EnergyUnits.MegawattDays); } /** * Create a new Energy instance from a GigawattDays * * @param value The unit as GigawattDays to create a new Energy from. * @returns The new Energy instance. */ static FromGigawattDays(value) { return new Energy(value, EnergyUnits.GigawattDays); } /** * Create a new Energy instance from a TerawattDays * * @param value The unit as TerawattDays to create a new Energy from. * @returns The new Energy instance. */ static FromTerawattDays(value) { return new Energy(value, EnergyUnits.TerawattDays); } /** * Create a new Energy instance from a DecathermsEc * * @param value The unit as DecathermsEc to create a new Energy from. * @returns The new Energy instance. */ static FromDecathermsEc(value) { return new Energy(value, EnergyUnits.DecathermsEc); } /** * Create a new Energy instance from a DecathermsUs * * @param value The unit as DecathermsUs to create a new Energy from. * @returns The new Energy instance. */ static FromDecathermsUs(value) { return new Energy(value, EnergyUnits.DecathermsUs); } /** * Create a new Energy instance from a DecathermsImperial * * @param value The unit as DecathermsImperial to create a new Energy from. * @returns The new Energy instance. */ static FromDecathermsImperial(value) { return new Energy(value, EnergyUnits.DecathermsImperial); } /** * Gets the base unit enumeration associated with Energy * @returns The unit enumeration that can be used to interact with this type */ static getUnitEnum() { return EnergyUnits; } /** * 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 */ static getBaseUnit() { return EnergyUnits.Joules; } /** * Create API DTO represent a Energy unit. * @param holdInUnit The specific Energy unit to be used in the unit representation at the DTO */ toDto(holdInUnit = EnergyUnits.Joules) { return { value: this.convert(holdInUnit), unit: holdInUnit }; } /** * Create a Energy unit from an API DTO representation. * @param dtoEnergy The Energy API DTO representation */ static FromDto(dtoEnergy) { return new Energy(dtoEnergy.value, dtoEnergy.unit); } /** * Convert Energy to a specific unit value. * @param toUnit The specific unit to convert to * @returns The value of the specific unit provided. */ convert(toUnit) { switch (toUnit) { case EnergyUnits.Joules: return this.Joules; case EnergyUnits.Calories: return this.Calories; case EnergyUnits.BritishThermalUnits: return this.BritishThermalUnits; case EnergyUnits.ElectronVolts: return this.ElectronVolts; case EnergyUnits.FootPounds: return this.FootPounds; case EnergyUnits.Ergs: return this.Ergs; case EnergyUnits.WattHours: return this.WattHours; case EnergyUnits.WattDays: return this.WattDays; case EnergyUnits.ThermsEc: return this.ThermsEc; case EnergyUnits.ThermsUs: return this.ThermsUs; case EnergyUnits.ThermsImperial: return this.ThermsImperial; case EnergyUnits.HorsepowerHours: return this.HorsepowerHours; case EnergyUnits.Nanojoules: return this.Nanojoules; case EnergyUnits.Microjoules: return this.Microjoules; case EnergyUnits.Millijoules: return this.Millijoules; case EnergyUnits.Kilojoules: return this.Kilojoules; case EnergyUnits.Megajoules: return this.Megajoules; case EnergyUnits.Gigajoules: return this.Gigajoules; case EnergyUnits.Terajoules: return this.Terajoules; case EnergyUnits.Petajoules: return this.Petajoules; case EnergyUnits.Kilocalories: return this.Kilocalories; case EnergyUnits.Megacalories: return this.Megacalories; case EnergyUnits.KilobritishThermalUnits: return this.KilobritishThermalUnits; case EnergyUnits.MegabritishThermalUnits: return this.MegabritishThermalUnits; case EnergyUnits.GigabritishThermalUnits: return this.GigabritishThermalUnits; case EnergyUnits.KiloelectronVolts: return this.KiloelectronVolts; case EnergyUnits.MegaelectronVolts: return this.MegaelectronVolts; case EnergyUnits.GigaelectronVolts: return this.GigaelectronVolts; case EnergyUnits.TeraelectronVolts: return this.TeraelectronVolts; case EnergyUnits.KilowattHours: return this.KilowattHours; case EnergyUnits.MegawattHours: return this.MegawattHours; case EnergyUnits.GigawattHours: return this.GigawattHours; case EnergyUnits.TerawattHours: return this.TerawattHours; case EnergyUnits.KilowattDays: return this.KilowattDays; case EnergyUnits.MegawattDays: return this.MegawattDays; case EnergyUnits.GigawattDays: return this.GigawattDays; case EnergyUnits.TerawattDays: return this.TerawattDays; case EnergyUnits.DecathermsEc: return this.DecathermsEc; case EnergyUnits.DecathermsUs: return this.DecathermsUs; case EnergyUnits.DecathermsImperial: return this.DecathermsImperial; default: break; } return Number.NaN; } convertFromBase(toUnit) { if (base_unit_1.areAnyOperatorsOverridden()) switch (toUnit) { case EnergyUnits.Joules: return this.value; case EnergyUnits.Calories: return super.internalDivide(this.value, 4.184); case EnergyUnits.BritishThermalUnits: return super.internalDivide(this.value, 1055.05585262); case EnergyUnits.ElectronVolts: return super.internalDivide(this.value, 1.602176634e-19); case EnergyUnits.FootPounds: return super.internalDivide(this.value, 1.3558179483314004); case EnergyUnits.Ergs: return super.internalDivide(this.value, 1e-7); case EnergyUnits.WattHours: return super.internalDivide(this.value, 3600); case EnergyUnits.WattDays: { const v4 = super.internalMultiply(24, 3600); return super.internalDivide(this.value, v4); } case EnergyUnits.ThermsEc: return super.internalDivide(this.value, 1.05505585262e8); case EnergyUnits.ThermsUs: return super.internalDivide(this.value, 1.054804e8); case EnergyUnits.ThermsImperial: return super.internalDivide(this.value, 1.05505585257348e8); case EnergyUnits.HorsepowerHours: { const v4 = super.internalMultiply(76.0402249, 9.80665); const v6 = super.internalMultiply(v4, 3600); return super.internalDivide(this.value, v6); } case EnergyUnits.Nanojoules: return super.internalDivide(this.value, 1e-9); case EnergyUnits.Microjoules: return super.internalDivide(this.value, 0.000001); case EnergyUnits.Millijoules: return super.internalDivide(this.value, 0.001); case EnergyUnits.Kilojoules: return super.internalDivide(this.value, 1000); case EnergyUnits.Megajoules: return super.internalDivide(this.value, 1000000); case EnergyUnits.Gigajoules: return super.internalDivide(this.value, 1000000000); case EnergyUnits.Terajoules: return super.internalDivide(this.value, 1000000000000); case EnergyUnits.Petajoules: return super.internalDivide(this.value, 1000000000000000); case EnergyUnits.Kilocalories: { const v3 = super.internalDivide(this.value, 4.184); return super.internalDivide(v3, 1000); } case EnergyUnits.Megacalories: { const v3 = super.internalDivide(this.value, 4.184); return super.internalDivide(v3, 1000000); } case EnergyUnits.KilobritishThermalUnits: { const v3 = super.internalDivide(this.value, 1055.05585262); return super.internalDivide(v3, 1000); } case EnergyUnits.MegabritishThermalUnits: { const v3 = super.internalDivide(this.value, 1055.05585262); return super.internalDivide(v3, 1000000); } case EnergyUnits.GigabritishThermalUnits: { const v3 = super.internalDivide(this.value, 1055.05585262); return super.internalDivide(v3, 1000000000); } case EnergyUnits.KiloelectronVolts: { const v3 = super.internalDivide(this.value, 1.602176634e-19); return super.internalDivide(v3, 1000); } case EnergyUnits.MegaelectronVolts: { const v3 = super.internalDivide(this.value, 1.602176634e-19); return super.internalDivide(v3, 1000000); } case EnergyUnits.GigaelectronVolts: { const v3 = super.internalDivide(this.value, 1.602176634e-19); return super.internalDivide(v3, 1000000000); } case EnergyUnits.TeraelectronVolts: { const v3 = super.internalDivide(this.value, 1.602176634e-19); return super.internalDivide(v3, 1000000000000); } case EnergyUnits.KilowattHours: { const v3 = super.internalDivide(this.value, 3600); return super.internalDivide(v3, 1000); } case EnergyUnits.MegawattHours: { const v3 = super.internalDivide(this.value, 3600); return super.internalDivide(v3, 1000000); } case EnergyUnits.GigawattHours: { const v3 = super.internalDivide(this.value, 3600); return super.internalDivide(v3, 1000000000); } case EnergyUnits.TerawattHours: { const v3 = super.internalDivide(this.value, 3600); return super.internalDivide(v3, 1000000000000); } case EnergyUnits.KilowattDays: { const v4 = super.internalMultiply(24, 3600); const v5 = super.internalDivide(this.value, v4); return super.internalDivide(v5, 1000); } case EnergyUnits.MegawattDays: { const v4 = super.internalMultiply(24, 3600); const v5 = super.internalDivide(this.value, v4); return super.internalDivide(v5, 1000000); } case EnergyUnits.GigawattDays: { const v4 = super.internalMultiply(24, 3600); const v5 = super.internalDivide(this.value, v4); return super.internalDivide(v5, 1000000000); } case EnergyUnits.TerawattDays: { const v4 = super.internalMultiply(24, 3600); const v5 = super.internalDivide(this.value, v4); return super.internalDivide(v5, 1000000000000); } case EnergyUnits.DecathermsEc: { const v3 = super.internalDivide(this.value, 1.05505585262e8); return super.internalDivide(v3, 10); } case EnergyUnits.DecathermsUs: { const v3 = super.internalDivide(this.value, 1.054804e8); return super.internalDivide(v3, 10); } case EnergyUnits.DecathermsImperial: { const v3 = super.internalDivide(this.value, 1.05505585257348e8); return super.internalDivide(v3, 10); } default: return Number.NaN; } switch (toUnit) { case EnergyUnits.Joules: return this.value; case EnergyUnits.Calories: return this.value / 4.184; case EnergyUnits.BritishThermalUnits: return this.value / 1055.05585262; case EnergyUnits.ElectronVolts: return this.value / 1.602176634e-19; case EnergyUnits.FootPounds: return this.value / 1.3558179483314004; case EnergyUnits.Ergs: return this.value / 1e-7; case EnergyUnits.WattHours: return this.value / 3600; case EnergyUnits.WattDays: return this.value / (24 * 3600); case EnergyUnits.ThermsEc: return this.value / 1.05505585262e8; case EnergyUnits.ThermsUs: return this.value / 1.054804e8; case EnergyUnits.ThermsImperial: return this.value / 1.05505585257348e8; case EnergyUnits.HorsepowerHours: return this.value / (76.0402249 * 9.80665 * 3600); case EnergyUnits.Nanojoules: return (this.value) / 1e-9; case EnergyUnits.Microjoules: return (this.value) / 0.000001; case EnergyUnits.Millijoules: return (this.value) / 0.001; case EnergyUnits.Kilojoules: return (this.value) / 1000; case EnergyUnits.Megajoules: return (this.value) / 1000000; case EnergyUnits.Gigajoules: return (this.value) / 1000000000; case EnergyUnits.Terajoules: return (this.value) / 1000000000000; case EnergyUnits.Petajoules: return (this.value) / 1000000000000000; case EnergyUnits.Kilocalories: return (this.value / 4.184) / 1000; case EnergyUnits.Megacalories: return (this.value / 4.184) / 1000000; case EnergyUnits.KilobritishThermalUnits: return (this.value / 1055.05585262) / 1000; case EnergyUnits.MegabritishThermalUnits: return (this.value / 1055.05585262) / 1000000; case EnergyUnits.GigabritishThermalUnits: return (this.value / 1055.05585262) / 1000000000; case EnergyUnits.KiloelectronVolts: return (this.value / 1.602176634e-19) / 1000; case EnergyUnits.MegaelectronVolts: return (this.value / 1.602176634e-19) / 1000000; case EnergyUnits.GigaelectronVolts: return (this.value / 1.602176634e-19) / 1000000000; case EnergyUnits.TeraelectronVolts: return (this.value / 1.602176634e-19) / 1000000000000; case EnergyUnits.KilowattHours: return (this.value / 3600) / 1000; case EnergyUnits.MegawattHours: return (this.value / 3600) / 1000000; case EnergyUnits.GigawattHours: return (this.value / 3600) / 1000000000; case EnergyUnits.TerawattHours: return (this.value / 3600) / 1000000000000; case EnergyUnits.KilowattDays: return (this.value / (24 * 3600)) / 1000; case EnergyUnits.MegawattDays: return (this.value / (24 * 3600)) / 1000000; case EnergyUnits.GigawattDays: return (this.value / (24 * 3600)) / 1000000000; case EnergyUnits.TerawattDays: return (this.value / (24 * 3600)) / 1000000000000; case EnergyUnits.DecathermsEc: return (this.value / 1.05505585262e8) / 10; case EnergyUnits.DecathermsUs: return (this.value / 1.054804e8) / 10; case EnergyUnits.DecathermsImperial: return (