Use the package manager npm or yarn to install.
npm install percify
or
yarn add percify
const percentage = require("percify");
/**
* returns "Percentage: 10%"
* params type number
*/
console.log("Percentage: " + percentage(150, 1500) + "%");
/**
* returns "Percentage: 10%"
* params type string
*/
console.log("Percentage: " + percentage("150", "1500") + "%");
/**
* Return formated value
*
*/
const percent = percentage(150, 1500).format();
console.log(percent); // returns "10%"
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.