Package Exports
- @hugoalh/temperature
Readme
Temperature (NodeJS)
| Release | Latest ( |
Pre ( |
|---|---|---|
| GitHub |
||
| NPM |
π Description
A NodeJS module to convert temperature units.
Units of temperature are from Wikipedia - Conversion of scales of temperature.
| Unit | Symbol (*: Exclusive) | Camel Case Name | Formula of Convert to SI Unit | Formula of Convert from SI Unit |
|---|---|---|---|---|
| Kelvin [SI] | K |
Kelvin / kelvin |
||
| Celsius | C |
Celsius / celsius |
$T_{K} = T_{C} + 273.15$ | $T_{C} = T_{K} - 273.15$ |
| Delisle | D / De* |
Delisle / delisle |
$T_{K} = 373.15 - T_{D} \div 1.5$ | $T_{D} = \left( 373.15 - T_{K} \right) \times 1.5$ |
| Fahrenheit | F |
Fahrenheit / fahrenheit |
$T_{K} = \left( T_{F} + 459.67 \right) \div 1.8$ | $T_{F} = T_{K} \times 1.8 - 459.67$ |
| Rankine | R / Ra |
Rankine / rankine |
$T_{K} = T_{R} \div 1.8$ | $T_{R} = T_{K} \times 1.8$ |
| RΓ©aumur | Re / r |
Reaumur / reaumur |
$T_{K} = T_{Re} \times 1.25 + 273.15$ | $T_{Re} = \left( T_{K} - 273.15 \right) \times 0.8$ |
| RΓΈmer | Ro |
Roemer / roemer / Romer / romer |
$T_{K} = \left( T_{Ro} - 7.5 \right) \div 0.525 + 273.15$ | $T_{Ro} = \left( T_{K} - 273.15 \right) \times 0.525 + 7.5$ |
| Sir Isaac Newton's degree of temperature (Newton) | N |
Newton / newton |
$T_{K} = T_{N} \div 0.33 + 273.15$ | $T_{N} = \left( T_{K} - 273.15 \right) \times 0.33$ |
π Note
- Degree symbol (
Β°) is not used in here. - In order to fulfill the JavaScript namespace naming requirement, some characters are replaced (e.g.:
Γ©toe,ΓΈtoo). - This module uses the built in JavaScript
Numbertype, which is a floating point number with a limited precision of 64 bits, about 16 digits. Floating point numbers round-off errors can occur during calculations:In most cases, round-off errors do not matter, they have no significant impact on the results. However, it looks ugly when displaying output to a user. A solution is to limit the precision just below the actual precision of 16 digits in the displayed output:0.1 + 0.2; //=> 0.30000000000000004
(0.1 + 0.2).toPrecision(14); //=> 0.3
π Documentation
Getting Started
Install
- NodeJS >= v6.9.0
- NPM >= v3.10.8
npm install @hugoalh/temperatureUse In CommonJS
const Temperature = require("@hugoalh/temperature");Use In ModuleJS
import Temperature from "@hugoalh/temperature";API
Class
new Temperature(value: number, unit?: string = "K"): Temperature
Temperature.difference(a: Temperature, b: Temperature): TemperatureDifferenceExample
new Temperature(25, "C").K
//=> 298.15
new Temperature(298.15).C
//=> 25