@contrail/aggregates
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -6,2 +6,5 @@ "use strict"; | ||
static getTotal(data, index) { | ||
if (!(data === null || data === void 0 ? void 0 : data.length)) { | ||
return; | ||
} | ||
let total = data.reduce(function (a, b) { | ||
@@ -16,2 +19,5 @@ if (b[index]) { | ||
static getAverage(data, index) { | ||
if (!(data === null || data === void 0 ? void 0 : data.length)) { | ||
return; | ||
} | ||
const withVal = data.filter(obj => (obj[index] !== undefined && obj[index] > 0)); | ||
@@ -26,6 +32,20 @@ const total = this.getTotal(data, index); | ||
static getMin(data, index) { | ||
return Math.min(...data.map(obj => obj[index] ? obj[index] : 0)); | ||
if (!(data === null || data === void 0 ? void 0 : data.length)) { | ||
return; | ||
} | ||
let val = Math.min(...data.map(obj => obj[index] ? obj[index] : 0)); | ||
if (val === Infinity) { | ||
return null; | ||
} | ||
return val; | ||
} | ||
static getMax(data, index) { | ||
return Math.max(...data.map(obj => obj[index] ? obj[index] : 0)); | ||
if (!(data === null || data === void 0 ? void 0 : data.length)) { | ||
return; | ||
} | ||
let val = Math.max(...data.map(obj => obj[index] ? obj[index] : 0)); | ||
if (val === Infinity) { | ||
return null; | ||
} | ||
return val; | ||
} | ||
@@ -32,0 +52,0 @@ static getUniqueCount(data, index) { |
{ | ||
"name": "@contrail/aggregates", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Utilities for computing aggregates", | ||
@@ -5,0 +5,0 @@ "main": "lib/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
4489
90