Round values up to an amount of decimals, avoiding the floating point weirdness of JavaScript.
npm install @alvarocastro/round
const round = require('@alvarocastro/round');
round(1.005);
// => 1.01
round(2.2222, 1);
// => 1.1
round(3, 5);
// => 3
Returns the value rounded up to a given amout of decimals.
Type: Number
Value to round.
Type: Number
Default: 2
The amount of decimals to round the number to.
Contributions are always welcome! Please run npm test
beforehand to ensure everything is ok.
If you use this package please consider starring it :)