Socket
Socket
Sign inDemoInstall

simple-common-utils

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-common-utils - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

14

js/StaticUtils.js

@@ -150,8 +150,16 @@ export default class StaticUtils {

static round(value, decimals) {
static round(value, decimals, symmetric) {
// https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary
// MarkG's answer.
return decimals == undefined ? value : Number(Math.
round(value + "e" + decimals) + "e-" + decimals);
let result = value;
if (decimals != undefined) {
const multiplier = !symmetric ? undefined : result < 0 ? -1 : 1;
result = Number(Math.round((multiplier ? Math.abs(result) : result) +
"e" + decimals) + "e-" + decimals) * (multiplier || 1);
}
return result;
}

@@ -158,0 +166,0 @@

{
"name": "simple-common-utils",
"version": "1.1.0",
"version": "1.2.0",
"description": "A collection of utility classes.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -147,5 +147,5 @@ This is a collection of utility classes used for JS development.

Rounds `value` to `decimals` digits after the decimal point. Thanks [MarkG](https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary)!
Rounds `value` to `decimals` digits after the decimal point (thanks, [MarkG](https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary)!). `symmetric` is used to achieve the same functionality both for negative and positive numbers.
StaticUtils.round(value, decimals);
StaticUtils.round(value, decimals, symmetric);

@@ -157,2 +157,4 @@ StaticUtils.round(10.2); // 10.2

StaticUtils.round(10.525, 2); // 10.53
StaticUtils.round(-1.5, 0); // -1
StaticUtils.round(-1.5, 0, true); // -2

@@ -236,2 +238,3 @@ - encodedUtf8ToByteArray()

-|-
v1.2.0|The parameter `symmetric` is added to `StaticUtils.round()` in a backwards-compatible way.
v1.1.0|The methods `StaticUtils.deg2Rad()` and `StaticUtils.color()` are added.

@@ -238,0 +241,0 @@ v1.0.0|Initial release.

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