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 | Symbol Lowercase | Name | Name Lowercase |
|---|---|---|---|---|
| Kelvin [SI] | K |
k |
Kelvin |
kelvin |
| Celsius | C |
c |
Celsius |
celsius |
| Delisle | De |
de |
Delisle |
delisle |
| Fahrenheit | F |
f |
Fahrenheit |
fahrenheit |
| Rankine | R |
r |
Rankine |
rankine |
| RΓ©aumur | Re |
re |
Reaumur |
reaumur |
| RΓΈmer | Ro |
ro |
Roemer, Romer |
roemer, romer |
| Sir Isaac Newton's degree of temperature (Newton) | N |
n |
Newton |
newton |
π 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