https://github.com/montyanderson/ratio-to-percentages
A very tiny NPM module for converting a multiple value ratio to an array of percentages.
https://github.com/montyanderson/ratio-to-percentages
Last synced: 3 months ago
JSON representation
A very tiny NPM module for converting a multiple value ratio to an array of percentages.
- Host: GitHub
- URL: https://github.com/montyanderson/ratio-to-percentages
- Owner: montyanderson
- License: mit
- Created: 2015-07-16T13:20:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-18T13:25:36.000Z (almost 10 years ago)
- Last Synced: 2025-03-01T06:39:47.312Z (4 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/ratio-to-percentages
- Size: 141 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ratio-to-percentages
[](https://www.npmjs.com/package/ratio-to-percentages)
[](https://travis-ci.org/montyanderson/ratio-to-percentages)A very tiny NPM module for converting a multiple value ratio to an array of percentages.
``` javascript
var rtp = require("ratio-to-percentages");rtp([100, 50, 50]);
// [ 50, 25, 25 ]rtp([1, 2]);
// [ 33.33333333333333, 66.66666666666666 ]// You can also parse in functions to be run on each value
rtp([1, 2], Math.round);
// [ 33, 67 ]rtp([1, 2], Math.floor);
// [ 33, 66 ]```