@khanisak/temperature-converter
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Temperature Converter

Lightweight javascript library to calculate Temperature values.

Installation

With npm :

npm install --save @khanisak/temperature-converter

Usage

import { Celcius, Fahrenheit, Kelvin } from '@khanisak/temperature-converter';

Use it

// "Celcius to Fahrenheit
const fahrenheit =  new Celcius(15).toFahrenheit(); 
console.log(fahrenheit.value); // will result 59
console.log(fahrenheit.unit); // { name: "Fahrenheit", code: "°F" }

// "Fahrenheit to Kelvin
const kelvin = new Fahrenheit(15).toKelvin();
console.log(kelvin.value); // will result 263.7055555555555
console.log(kelvin.unit); // { name: "Kelvin", code: "°K" }

// "Kelvin to Celcius
const celcius = new Kelvin(15).toCelcius();
console.log(celcius.value); // will result -258.15
console.log(celcius.unit); // { name: "Celcius", code: "°C" }

list all temperature units available

import { units } from '@khanisak/temperature-converter';

console.log(units);

Temperature Property

Name Type Description
value number value of current temperature
unit object name and code of current unit. ex: { name: "Celcius", code: '°C' }

License

This project is licensed under the MIT License

Package Sidebar

Install

npm i @khanisak/temperature-converter

Weekly Downloads

25

Version

2.0.1

License

MIT

Unpacked Size

35.4 kB

Total Files

30

Last publish

Collaborators

  • khanisak