Package Exports
- @hugoalh/temperature
- @hugoalh/temperature/lib/main.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hugoalh/temperature) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Temperature (NodeJS)
| Releases | Latest ( |
Pre ( |
|---|---|---|
📝 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 |
|---|---|---|
| Kelvin [SI] | K |
Kelvin / kelvin |
| Celsius | C |
Celsius / celsius |
| Delisle | D / De* |
Delisle / delisle |
| Fahrenheit | F |
Fahrenheit / fahrenheit |
| Rankine | R / Ra |
Rankine / rankine |
| Réaumur | Re / r |
Reaumur / reaumur |
| Rømer | Ro |
Roemer / roemer / Romer / romer |
| Sir Isaac Newton's degree of temperature (Newton) | N |
Newton / newton |
Conversion Formula
| Unit | To SI Unit | From SI Unit |
|---|---|---|
| Kelvin [SI] | ||
| Celsius | $T_{K} = T_{C} + 273.15$ | $T_{C} = T_{K} - 273.15$ |
| Delisle | $T_{K} = 373.15 - T_{D} \div 1.5$ | $T_{D} = \left( 373.15 - T_{K} \right) \times 1.5$ |
| Fahrenheit | $T_{K} = \left( T_{F} + 459.67 \right) \div 1.8$ | $T_{F} = T_{K} \times 1.8 - 459.67$ |
| Rankine | $T_{K} = T_{R} \div 1.8$ | $T_{R} = T_{K} \times 1.8$ |
| Réaumur | $T_{K} = T_{Re} \times 1.25 + 273.15$ | $T_{Re} = \left( T_{K} - 273.15 \right) \times 0.8$ |
| Rømer | $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) | $T_{K} = T_{N} \div 0.33 + 273.15$ | $T_{N} = \left( T_{K} - 273.15 \right) \times 0.33$ |
📋 Notice
- 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 install @hugoalh/temperatureUse
CommonJS
const Temperature = require("@hugoalh/temperature");ModuleJS
import Temperature from "@hugoalh/temperature";API
Class
new Temperature(value: number, unit: string = "K"): Temperature;
.C: number;
.D: number;
.F: number;
.K: number;
.N: number;
.R: number;
.Re: number;
.Ro: number;
Temperature.difference(a: Temperature, b: Temperature): TemperatureDifference;Example
new Temperature(25, "C").K;
//=> 298.15
new Temperature(298.15).C;
//=> 25