@toolsnap/percentage-calculator
v1.0.0
Published
Lightweight percentage calculation utilities for Node.js and browsers.
Maintainers
Readme
@toolsnap/percentage-calculator
Lightweight, zero-dependency percentage calculation utilities for Node.js and browsers.
Installation
npm install @toolsnap/percentage-calculatorUsage
const { of, ofValue, change, increase, decrease } = require('@toolsnap/percentage-calculator');
of(25, 200); // 12.5 — 25 is 12.5% of 200
ofValue(15, 200); // 30 — 15% of 200
change(80, 100); // 25 — 25% increase
increase(100, 20); // 120 — 100 + 20%
decrease(100, 20); // 80 — 100 - 20%API
| Function | Description |
|----------|-------------|
| of(part, total) | What percentage part is of total |
| ofValue(percent, value) | percent% of value |
| change(oldVal, newVal) | Percentage change between two values |
| increase(value, percent) | Increase value by percentage |
| decrease(value, percent) | Decrease value by percentage |
Online Tool
Try our free online percentage calculator — no install needed.
License
MIT
