Comparing version 1.0.0 to 1.1.0
10
index.js
@@ -9,7 +9,11 @@ 'use strict'; | ||
if (!numberIsInteger(precision) || precision < 0) { | ||
throw new TypeError('Expected precision to be a positive integer'); | ||
if (!numberIsInteger(precision)) { | ||
throw new TypeError('Expected precision to be an integer'); | ||
} | ||
return Number(Math[fn](x + 'e' + precision) + 'e-' + precision); | ||
var exponent = precision > 0 ? 'e' : 'e-'; | ||
var exponentNeg = precision > 0 ? 'e-' : 'e'; | ||
precision = Math.abs(precision); | ||
return Number(Math[fn](x + exponent + precision) + exponentNeg + precision); | ||
} | ||
@@ -16,0 +20,0 @@ |
{ | ||
"name": "round-to", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Round a number to a specific number of decimal places: 1.234 → 1.2", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -28,3 +28,9 @@ # round-to [![Build Status](https://travis-ci.org/sindresorhus/round-to.svg?branch=master)](https://travis-ci.org/sindresorhus/round-to) | ||
Numbers are rounded to a specific number of significant figures. Specifying a negative precision will round to any number of places to the left of the decimal. | ||
```js | ||
roundTo(1234.56, -2); | ||
//=> 1200 | ||
``` | ||
## API | ||
@@ -50,3 +56,3 @@ | ||
Type: `number` (positive integer) | ||
Type: `number` (integer) | ||
@@ -53,0 +59,0 @@ Number of decimal places. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3749
17
63