An ECMAScript module to convert between units of the temperature.
These units of the temperature are supported:
| Names | Symbols | ||
|---|---|---|---|
| [SI] | Kelvin | Kelvin |
K |
| Celsius | Celsius |
°C / C |
|
| Delisle | Delisle |
°De / De / D |
|
| Fahrenheit | Fahrenheit |
°F / F |
|
| Newton * | Newton |
°N / N |
|
| Rankine | Rankine |
°R / R / Ra |
|
| Réaumur | Réaumur / Reaumur |
°Ré / Re / r |
|
| Rømer | Rømer / Roemer / Romer |
°Rø / Ro |
* Sir Isaac Newton's degree of temperature
| Runtime \ Source | GitHub Raw | JSR | NPM |
|---|---|---|---|
| Bun >= v1.1.0 | ❌ | ✔️ | ✔️ |
| Deno >= v2.1.0 | ✔️ | ✔️ | ✔️ |
| NodeJS >= v20.9.0 | ❌ | ✔️ | ✔️ |
- GitHub Raw
https://raw.githubusercontent.com/hugoalh/temperature-es/{Tag}/mod.ts - JSR
jsr:@hugoalh/temperature[@{Tag}] - NPM
npm:@hugoalh/temperature[@{Tag}]
Note
- It is recommended to include tag for immutability.
- These are not part of the public APIs hence should not be used:
- Benchmark/Test file (e.g.:
example.bench.ts,example.test.ts). - Entrypoint name or path include any underscore prefix (e.g.:
_example.ts,foo/_example.ts). - Identifier/Namespace/Symbol include any underscore prefix (e.g.:
_example,Foo._example).
- Benchmark/Test file (e.g.:
This module does not request any runtime permission.
-
class Temperature { constructor(fromValue: number, fromUnit?: TemperatureUnitsInputs); toObject(): Record<TemperatureUnitsSymbolASCII, number>; toString(toUnit?: TemperatureUnitsInputs): string; toValue(toUnit?: TemperatureUnitsInputs): number; static unit(unit?: TemperatureUnitsInputs): TemperatureUnitMeta; static units(): TemperatureUnitMeta[]; }
Note
- For the full or prettier documentation, can visit via:
-
new Temperature(25, "C").toValue(); //=> 298.15
-
new Temperature(25, "C").toString(); //=> "298.15 K"
-
new Temperature(298.15).toValue("C"); //=> 25
-
new Temperature(298.15).toString("C"); //=> "25 °C"
- Wikipedia