Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

round-to

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

round-to - npm Package Compare versions

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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc