ratio-to-percentages
v0.0.4
Published
A very tiny NPM module for converting a multiple value ratio to an array of percentages.
Downloads
3
Readme
ratio-to-percentages
A very tiny NPM module for converting a multiple value ratio to an array of percentages.
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 ]