Skip to content

alvarocastro/round

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Round

NPM Build status Maintainability status Coverage status Bundle size Code style: XO Release: Semantic

Round values up to an amount of decimals, avoiding the floating point weirdness of JavaScript.

Install

npm install @alvarocastro/round

Usage

const round = require('@alvarocastro/round');

round(1.005);
// => 1.01
round(2.2222, 1);
// => 1.1
round(3, 5);
// => 3

round(number[, decimals = 2])

Returns the value rounded up to a given amout of decimals.

number

Type: Number

Value to round.

decimals

Type: Number
Default: 2

The amount of decimals to round the number to.

Contributing

Contributions are always welcome! Please run npm test beforehand to ensure everything is ok.

Support

If you use this package please consider starring it :)