Skip to content
/ pruni Public

Calculation of information units in any form and any format.

License

Notifications You must be signed in to change notification settings

oritwoen/pruni

Repository files navigation

pruni

npm version npm size npm downloads license

Calculation of information units in any form and any format.

Why?

When I wanted to create a script for calculating the profitability of cryptocurrency mining, I encountered a problem with formatting information units to one format from all potential formats.

I didn't feel like formatting or converting it in different formats every time, so I created this package.

Install

npm install --save pruni

# Using pnpm
pnpm add pruni

# Using yarn
yarn add pruni

Usage

import { useCalculatedUnits } from 'pruni'

//Number
useCalculatedUnits(9, 'megabytes', 'kilobytes') // return 9000
useCalculatedUnits(7, 'mh/s', 'kilohash per second') // return 7000
useCalculatedUnits(3, 'mega sol per second', 'ks/s') // return 3000

//Pretty
useCalculatedUnits(1, 'mb', 'kb', { pretty: true }) // return 1000 KB
useCalculatedUnits(1, 'gh', 'mh', { pretty: true, unit: 'h' }) // return 1000 MH
useCalculatedUnits(1, 'msol', 'ksol', { pretty: true, unit: 'sol' }) // return 1000 KSOL

License

MIT License © 2023 Dominik Opyd