You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

graphology-assertions

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-assertions - npm Package Compare versions

Comparing version

to
2.2.1

68

index.js

@@ -8,7 +8,52 @@ /**

var deepEqual = require('fast-deep-equal/es6');
var objectHash = require('object-hash');
/**
* Constants.
*/
var SIZE = Symbol('size');
/**
* Helpers.
*/
function areUnorderedCollectionsOfAttributesIdentical(a1, a2) {
var l1 = a1.length;
var l2 = a2.length;
if (l1 !== l2) return false;
var o1, o2;
var i, j;
var matches = new Set();
outside: for (i = 0; i < l1; i++) {
o1 = a1[i];
for (j = 0; j < l2; j++) {
if (matches.has(j)) continue;
o2 = a2[j];
if (deepEqual(o1, o2)) {
matches.add(j);
continue outside;
}
}
return false;
}
return true;
}
function compareNeighborEntries(entries1, entries2) {
if (entries1[SIZE] !== entries2[SIZE]) return false;
for (var k in entries1) {
if (!areUnorderedCollectionsOfAttributesIdentical(entries1[k], entries2[k]))
return false;
}
return true;
}
function countOutEdges(graph, node) {

@@ -48,2 +93,3 @@ var counts = {};

var entries = {};
entries[SIZE] = 0;
var c;

@@ -56,12 +102,9 @@

c = [];
entries[SIZE] += 1;
entries[target] = c;
}
c.push(objectHash(attr));
c.push(attr);
});
for (var k in entries) {
entries[k].sort();
}
return entries;

@@ -72,2 +115,3 @@ }

var entries = {};
entries[SIZE] = 0;
var c;

@@ -84,12 +128,9 @@

c = [];
entries[SIZE] += 1;
entries[target] = c;
}
c.push(objectHash(attr));
c.push(attr);
});
for (var k in entries) {
entries[k].sort();
}
return entries;

@@ -201,2 +242,3 @@ }

var aggregationFunction = deep ? collectOutEdges : countOutEdges;
var comparisonFunction = deep ? compareNeighborEntries : deepEqual;

@@ -207,3 +249,3 @@ sameDirectedEdges = G.everyNode(function (node) {

return deepEqual(gCounts, hCounts);
return comparisonFunction(gCounts, hCounts);
});

@@ -221,3 +263,3 @@

return deepEqual(gCounts, hCounts);
return comparisonFunction(gCounts, hCounts);
});

@@ -224,0 +266,0 @@

5

package.json
{
"name": "graphology-assertions",
"version": "2.2.0",
"version": "2.2.1",
"description": "Assertions for graphology.",

@@ -38,5 +38,4 @@ "main": "index.js",

"fast-deep-equal": "^3.1.3",
"graphology-utils": "^2.1.2",
"object-hash": "2.2.0"
"graphology-utils": "^2.1.2"
}
}