https://github.com/kevva/calc-percent
Calculate percentage
https://github.com/kevva/calc-percent
calc nodejs percent
Last synced: about 1 year ago
JSON representation
Calculate percentage
- Host: GitHub
- URL: https://github.com/kevva/calc-percent
- Owner: kevva
- License: mit
- Created: 2015-03-13T18:49:02.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-25T13:25:43.000Z (about 9 years ago)
- Last Synced: 2025-05-06T23:02:42.212Z (about 1 year ago)
- Topics: calc, nodejs, percent
- Language: JavaScript
- Homepage:
- Size: 133 KB
- Stars: 21
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# calc-percent [](https://travis-ci.org/kevva/calc-percent)
> Calculate percentage
## Install
```
$ npm install --save calc-percent
```
## Usage
```js
var calcPercent = require('calc-percent');
calcPercent(10, 50);
//=> '20'
calcPercent(10, 50, {suffix: '%'});
//=> '20%'
calcPercent(100 / 3, 100, {decimal: 2});
//=> '33.33'
```
## API
### calcPercent(val, total, options)
#### val
Type: `number`
Value which should be calculated.
#### total
Type: `number`
Total that `val` should be compared against.
#### options.decimal
Type: `number`
Default: `0`
Number of decimals.
#### options.suffix
Type: `string`
Append a suffix.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)