Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/twlite/temperature

Simple package for deno to convert temperature.
https://github.com/twlite/temperature

Last synced: about 1 month ago
JSON representation

Simple package for deno to convert temperature.

Awesome Lists containing this project

README

        

# Temperature
Simple package for deno to convert temperature.

> **[Click here for nodejs version](https://npmjs.com/package/node-temperature-converter)**

# Features
- simple
- fast
- easy to use

# Example

```ts
import Converter from "https://raw.githubusercontent.com/Snowflake107/temperature/master/mod.ts";

// celsius
const celsius = new Converter.Celsius(35);

const obc = {
name: "Celsius",
deg: celsius.degrees,
fah: celsius.toFahrenheit(),
kel: celsius.toKelvin(),
str: celsius.toString(),
};
console.table(obc);

/*
Expected Output:
┌───────┬───────────┐
│ (idx) │ Values │
├───────┼───────────┤
│ name │ "Celsius" │
│ deg │ 35 │
│ fah │ 95 │
│ kel │ 308.15 │
│ str │ "35°C" │
└───────┴───────────┘
*/

// fahrenheit
const fahrenheit = new Converter.Fahrenheit(95);

const obf = {
name: "Fahrenheit",
deg: fahrenheit.degrees,
cel: fahrenheit.toCelsius(),
kel: fahrenheit.toKelvin(),
str: fahrenheit.toString(),
};
console.table(obf);

/*
Expected Output:
┌───────┬──────────────┐
│ (idx) │ Values │
├───────┼──────────────┤
│ name │ "Fahrenheit" │
│ deg │ 95 │
│ cel │ 35 │
│ kel │ 308.15 │
│ str │ "95°F" │
└───────┴──────────────┘
*/

// kelvin
const kelvin = new Converter.Kelvin(308.15);

const obk = {
name: "Kelvin",
deg: kelvin.degrees,
cel: kelvin.toCelsius(),
fah: kelvin.toFahrenheit(),
str: kelvin.toString(),
};
console.table(obk);

/*
Expected Output:
┌───────┬───────────┐
│ (idx) │ Values │
├───────┼───────────┤
│ name │ "Kelvin" │
│ deg │ 308.15 │
│ cel │ 35 │
│ fah │ 95 │
│ str │ "308.15K" │
└───────┴───────────┘
*/

```

# Running (No permissions required)

```sh
deno run
```