pruni
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

pruni

npm version npm size npm downloads

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

Package Sidebar

Install

npm i pruni

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

7.11 kB

Total Files

6

Last publish

Collaborators

  • oritwoen