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

@contrail/aggregates

Package Overview
Dependencies
Maintainers
8
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrail/aggregates - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

1

lib/aggregate-helper.d.ts

@@ -8,3 +8,4 @@ export declare class AggregateHelper {

static getValueCounts(data: Array<any>, index: any, values: Array<string>): {};
private static testValue;
static getGroupTotals(data: Array<any>, groupingIndex: string, groupingValues: Array<string>, totalIndex: string): {};
}

@@ -61,3 +61,5 @@ "use strict";

static getUniqueCount(data, index) {
return [...new Set(data.filter(obj => util_1.ObjectUtil.getByPath(obj, index)).map(obj => util_1.ObjectUtil.getByPath(obj, index)))].length;
return [...new Set(data.filter(obj => util_1.ObjectUtil.getByPath(obj, index))
.map(obj => util_1.ObjectUtil.getByPath(obj, index)))
].length;
}

@@ -67,10 +69,24 @@ static getValueCounts(data, index, values) {

for (const val of values) {
counts[val] = data.filter(obj => util_1.ObjectUtil.getByPath(obj, index) === val).length;
const filtered = data.filter(obj => {
const testValue = util_1.ObjectUtil.getByPath(obj, index);
return AggregateHelper.testValue(val, testValue);
});
counts[val] = filtered.length;
}
return counts;
}
static testValue(value, testValue) {
if (Array.isArray(testValue)) {
return testValue.includes(value);
}
return value === testValue;
}
static getGroupTotals(data, groupingIndex, groupingValues, totalIndex) {
const totals = {};
groupingValues.forEach(val => {
totals[val] = this.getTotal(data.filter(obj => util_1.ObjectUtil.getByPath(obj, groupingIndex) === val), totalIndex);
const filtered = data.filter(obj => {
const testValue = util_1.ObjectUtil.getByPath(obj, groupingIndex);
return AggregateHelper.testValue(val, testValue);
});
totals[val] = this.getTotal(filtered, totalIndex);
});

@@ -77,0 +93,0 @@ return totals;

export * from './aggregate-helper';

@@ -0,0 +0,0 @@ "use strict";

2

package.json
{
"name": "@contrail/aggregates",
"version": "1.0.6",
"version": "1.0.7",
"description": "Utilities for computing aggregates",

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

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