New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@contrail/data-grouping

Package Overview
Dependencies
Maintainers
9
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrail/data-grouping - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

1

lib/data-group-generator/data-group-generator.d.ts
import { DataGroup, DataGroupStructure, DataGroupingProperty } from "../interfaces";
export declare class DataGroupGenerator {
static getDistinctValues(data: any, index: any): any[];
static buildChildDataGroups(data: any, parentGroup: DataGroup, groupingProperties: Array<DataGroupingProperty>, leafNodeDataCount: any, currentDepth: any): void;

@@ -4,0 +5,0 @@ static buildDataGroupStructure(data: Array<any>, groupingProperties: Array<DataGroupingProperty>, leafNodeDataCount: number, currentDepth?: number): DataGroupStructure;

@@ -7,10 +7,26 @@ "use strict";

class DataGroupGenerator {
static getDistinctValues(data, index) {
const map = new Map();
data.forEach(obj => {
if (!obj) {
return;
}
let key = obj[index];
let value = key;
if (typeof key === 'object') {
key = value.id || value.name || value;
}
map[key] = value;
});
const distinctValues = [...(Object.values(map))].sort((v1, v2) => {
let val1 = (typeof v1 === 'object') ? v1.name : v1;
let val2 = (typeof v2 === 'object') ? v2.name : v2;
return val1 > val2 ? 1 : -1;
});
return distinctValues;
}
static buildChildDataGroups(data, parentGroup, groupingProperties, leafNodeDataCount, currentDepth) {
const groupingProperty = groupingProperties[currentDepth];
const index = groupingProperty.scope + "." + groupingProperty.property.slug;
const distinctValues = [...new Set(data.filter(obj => util_1.ObjectUtil.getByPath(obj, index))
.map(obj => util_1.ObjectUtil.getByPath(obj, index)))
].sort((v1, v2) => {
return v1 > v2 ? 1 : -1;
});
const distinctValues = this.getDistinctValues(data, index);
for (let val of distinctValues) {

@@ -17,0 +33,0 @@ const groupData = data.filter(obj => util_1.ObjectUtil.getByPath(obj, index) === val);

3

package.json
{
"name": "@contrail/data-grouping",
"version": "1.0.11",
"version": "1.0.12",
"description": "Utilities and interfaces for grouping data into hierarchial data structures based on properties.",

@@ -17,2 +17,3 @@ "main": "lib/index.js",

"devDependencies": {
"@contrail/util": "^1.0.26",
"@types/jest": "^23.3.14",

@@ -19,0 +20,0 @@ "jest": "^23.6.0",

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