Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoSign in
Socket

p-graph

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-graph - npm Package Compare versions

Comparing version
1.1.0
to
1.1.1
+16
-1
CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Thu, 22 Oct 2020 19:44:33 GMT",
"date": "Tue, 13 Apr 2021 06:46:44 GMT",
"tag": "p-graph_v1.1.1",
"version": "1.1.1",
"comments": {
"patch": [
{
"comment": "add descriptive error message when there is a cyclic dependancy",
"author": "cheruiyotbryan@gmail.com",
"commit": "123d9fa7148558b9e7e9100b1b57e2ce4d3a8e11",
"package": "p-graph"
}
]
}
},
{
"date": "Thu, 22 Oct 2020 19:44:39 GMT",
"tag": "p-graph_v1.1.0",

@@ -8,0 +23,0 @@ "version": "1.1.0",

# Change Log - p-graph
This log was last generated on Thu, 22 Oct 2020 19:44:33 GMT and should not be manually modified.
This log was last generated on Tue, 13 Apr 2021 06:46:44 GMT and should not be manually modified.
<!-- Start content -->
## 1.1.1
Tue, 13 Apr 2021 06:46:44 GMT
### Patches
- add descriptive error message when there is a cyclic dependancy (cheruiyotbryan@gmail.com)
## 1.1.0
Thu, 22 Oct 2020 19:44:33 GMT
Thu, 22 Oct 2020 19:44:39 GMT

@@ -11,0 +19,0 @@ ### Minor changes

+3
-2

@@ -123,3 +123,3 @@ "use strict";

});
it("throws an exception when the dependency graph has a cycle", async () => {
it("throws an exception with detailed message when the dependency graph has a cycle", async () => {
// This is almost the same as the last test, except the root node is not a part of the cycle

@@ -138,3 +138,4 @@ const nodeMap = new Map([

];
expect(() => index_1.default(nodeMap, dependencies)).toThrow();
const expectedErrorMessage = "The dependency graph has a cycle at B which depends on A,D and is depended on by C";
expect(() => index_1.default(nodeMap, dependencies)).toThrow(expectedErrorMessage);
});

@@ -141,0 +142,0 @@ it("resolves an empty dependnecy graph", async () => {

@@ -1,5 +0,6 @@

import { PGraphNodeWithDependencies } from "./types";
import { PGraphNodeWithCyclicDependency, PGraphNodeWithNoCyclicDependency, PGraphNodeWithDependencies } from "./types";
/**
* Checks for any cycles in the dependency graph, returning false if no cycles were detected.
* Checks for any cycles in the dependency graph, returning `{ hasCycle: false }` if no cycles were detected.
* Otherwise it returns the details of where the cycle was detected.
*/
export declare function graphHasCycles(pGraphDependencyMap: Map<string, PGraphNodeWithDependencies>): boolean;
export declare function graphHasCycles(pGraphDependencyMap: Map<string, PGraphNodeWithDependencies>): PGraphNodeWithCyclicDependency | PGraphNodeWithNoCyclicDependency;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Checks for any cycles in the dependency graph, returning false if no cycles were detected.
* Checks for any cycles in the dependency graph, returning `{ hasCycle: false }` if no cycles were detected.
* Otherwise it returns the details of where the cycle was detected.
*/

@@ -14,3 +15,3 @@ function graphHasCycles(pGraphDependencyMap) {

const visitMap = new Map();
for (const [nodeId] of pGraphDependencyMap.entries()) {
for (const [nodeId, nodes] of pGraphDependencyMap.entries()) {
/**

@@ -24,7 +25,14 @@ * Test whether this node has already been visited or not.

if (hasCycleDFS(pGraphDependencyMap, visitMap, nodeId)) {
return true;
return {
hasCycle: true,
details: {
nodeId,
dependsOn: Array.from(nodes.dependsOn),
dependedOnBy: Array.from(nodes.dependedOnBy)
}
};
}
}
}
return false;
return { hasCycle: false };
}

@@ -31,0 +39,0 @@ exports.graphHasCycles = graphHasCycles;

@@ -28,4 +28,6 @@ "use strict";

}
if (graphHasCycles_1.graphHasCycles(this.pGraphDependencyMap)) {
throw new Error("The dependency graph has a cycle in it");
const hasCycles = graphHasCycles_1.graphHasCycles(this.pGraphDependencyMap);
if (hasCycles.hasCycle) {
const { nodeId, dependsOn, dependedOnBy } = hasCycles.details;
throw new Error(`The dependency graph has a cycle at ${nodeId} which depends on ${dependsOn} and is depended on by ${dependedOnBy}`);
}

@@ -105,3 +107,3 @@ }

// if a continue option is set, this merely records what errors have been encountered
// it'll continue down the execution until all the tasks that still works
// it'll continue down the execution until all the tasks that still works
if (options === null || options === void 0 ? void 0 : options.continue) {

@@ -108,0 +110,0 @@ trySchedulingTasks();

@@ -47,1 +47,30 @@ /**

}
export interface PGraphNodeWithNoCyclicDependency {
/**
* Flag whether there is no cyclic dependency
*/
hasCycle: false;
}
export interface PGraphNodeWithCyclicDependency {
/**
* Flag whether there is a cyclic dependency
*/
hasCycle: true;
/**
* Details on where the cyclic dependency was detected.
*/
details: {
/**
* The identifier of this node, where the cyclic dependency was detected
*/
nodeId: string;
/**
* The set of nodes that this node depends on.
*/
dependsOn: string[];
/**
* The set of nodes that depend on this node.
*/
dependedOnBy: string[];
};
}
{
"name": "p-graph",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",

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