https://github.com/bendrucker/round.js
Round numbers to the nearest multiple with an optional direction
https://github.com/bendrucker/round.js
Last synced: 5 months ago
JSON representation
Round numbers to the nearest multiple with an optional direction
- Host: GitHub
- URL: https://github.com/bendrucker/round.js
- Owner: bendrucker
- License: mit
- Created: 2014-11-09T22:17:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T21:22:05.000Z (almost 7 years ago)
- Last Synced: 2025-10-11T07:28:28.659Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
round.js [](https://travis-ci.org/bendrucker/round.js) [](https://greenkeeper.io/)
========
> Round numbers to the nearest multiple with an optional direction.
## Installing
```js
$ npm install --save round
```
## API
#### `round(value, [multiple], [direction])` -> `number`
##### value
*Required*
Type: `number`
The value to round.
##### multiple
Type: `number`
Default: `1`
The multiple to round to.
##### direction
Type: `string`
Values: `up` / `down`
If no direction is supplied, the number will be rounded to the nearest direction, defaulting to up if the value is equidistant from the rounded values.
#### `round.down(value, multiple)` -> `number`
Convenience method for rounding down.
#### `round.up(value, multiple)` -> `number`
Convenience method for rounding up.