JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q18594F
  • License MIT

A module to convert temperature units.

Package Exports

  • @hugoalh/temperature

Readme

Temperature (NodeJS)

Temperature.NodeJS GitHub Contributors GitHub Issues GitHub Pull Requests GitHub Discussions GitHub Stars GitHub Forks GitHub Languages CodeFactor Grade License

Release Latest (GitHub Latest Release Date) Pre (GitHub Latest Pre-Release Date)
GitHub GitHub Total Downloads GitHub Latest Release Version GitHub Latest Pre-Release Version
NPM NPM Total Downloads NPM Latest Release Version NPM Latest Pre-Release Version

πŸ“ 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.: Γ© to e, ΓΈ to o).
  • This module uses the built in JavaScript Number type, 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:
    0.1 + 0.2;
    //=> 0.30000000000000004
    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).toPrecision(14);
    //=> 0.3

πŸ“š Documentation

Getting Started

Install

  • NodeJS >= v6.9.0
  • NPM >= v3.10.8
npm install @hugoalh/temperature

Use 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): TemperatureDifference

Example

new Temperature(25, "C").K
//=> 298.15

new Temperature(298.15).C
//=> 25