Comparing version 1.0.1 to 1.0.2
@@ -14,2 +14,3 @@ 'use strict'; | ||
}; | ||
const PRECISION = 10000; | ||
const CONFIG = Symbol('CONFIG'); | ||
@@ -123,7 +124,9 @@ const TIMES_TO_IDLE = Symbol('TIMES_TO_IDLE'); | ||
static [TIMES_TO_IDLE](times) { | ||
if (!(times instanceof Object) || !times.idle || !times.total) { | ||
if (!(times instanceof Object) | ||
|| !Number.isInteger(times.idle) || times.idle <= 0 | ||
|| !Number.isInteger(times.total) || times.total <= 0) { | ||
return 0.0; | ||
} | ||
const percent = Math.round(100 * times.idle / times.total) / 100; | ||
// console.log(times.idle, times.total, percent); | ||
const percent = Math.round(PRECISION * times.idle / times.total) / PRECISION; | ||
console.log(times.idle, times.total, percent); | ||
return percent; | ||
@@ -130,0 +133,0 @@ } |
{ | ||
"name": "cpu-idle", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Get cpu load info", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
7467
156