https://github.com/ragnarpa/quantity
A library for converting quantities with multipliers to real numbers.
https://github.com/ragnarpa/quantity
binary-prefix kubernetes-quantity multiple quantity si-prefix
Last synced: 5 months ago
JSON representation
A library for converting quantities with multipliers to real numbers.
- Host: GitHub
- URL: https://github.com/ragnarpa/quantity
- Owner: ragnarpa
- License: mit
- Created: 2021-02-27T13:21:17.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-27T22:22:16.000Z (over 5 years ago)
- Last Synced: 2025-10-06T18:49:43.312Z (9 months ago)
- Topics: binary-prefix, kubernetes-quantity, multiple, quantity, si-prefix
- Language: TypeScript
- Homepage:
- Size: 77.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Quantity with (sub)multipliers to real numbers
A library for converting quantities with multipliers to real numbers. Motivated by Kubernetes' API machinery quantity.
## Installation
```
npm install @ragnarpa/quantity
```
## Example usage
```javascript
const { real } = require("@ragnarpa/quantity");
const giga = real("10G");
const gibi = real("100Gi");
const micro = real("1000u");
console.log(giga, gibi, micro);
```
## Supported (sub)multipliers
| Multiplier | Unit prefix |
| ---------- | ----------- |
| n | nano |
| u | micro |
| m | milli |
| k | kilo |
| M | mega |
| G | giga |
| T | tera |
| P | peta |
| E | exa |
| Ki | kibi |
| Mi | mebi |
| Gi | gibi |
| Ti | tebi |
| Pi | pebi |
| Ei | exbi |