Socket
Socket
Sign inDemoInstall

@snyk/dep-graph

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snyk/dep-graph - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

3

dist/core/dep-graph.d.ts

@@ -14,2 +14,3 @@ import * as graphlib from 'graphlib';

private _rootPkgId;
private _countNodePathsToRootCache;
constructor(graph: graphlib.Graph, rootNodeId: string, pkgs: {

@@ -30,4 +31,6 @@ [pkgId: string]: types.PkgInfo;

pkgPathsToRoot(pkg: types.Pkg): types.PkgInfo[][];
countPathsToRoot(pkg: types.Pkg): number;
toJSON(): types.DepGraphData;
private pathsFromNodeToRoot;
private countNodePathsToRoot;
}

@@ -7,2 +7,3 @@ "use strict";

function DepGraphImpl(graph, rootNodeId, pkgs, pkgNodes, pkgManager) {
this._countNodePathsToRootCache = new Map();
this._graph = graph;

@@ -80,8 +81,5 @@ this._pkgs = pkgs;

var pathsToRoot = [];
var nodeIds = this.getPkgNodeIds(pkg);
if (nodeIds) {
for (var _i = 0, nodeIds_1 = nodeIds; _i < nodeIds_1.length; _i++) {
var id = nodeIds_1[_i];
pathsToRoot.push.apply(pathsToRoot, this.pathsFromNodeToRoot(id));
}
for (var _i = 0, _a = this.getPkgNodeIds(pkg); _i < _a.length; _i++) {
var id = _a[_i];
pathsToRoot.push.apply(pathsToRoot, this.pathsFromNodeToRoot(id));
}

@@ -92,2 +90,14 @@ // note: sorting to get shorter paths first -

};
DepGraphImpl.prototype.countPathsToRoot = function (pkg) {
// TODO: implement cycles support
if (this.hasCycles()) {
throw new Error('countPathsToRoot does not support cyclic graphs yet');
}
var count = 0;
for (var _i = 0, _a = this.getPkgNodeIds(pkg); _i < _a.length; _i++) {
var nodeId = _a[_i];
count += this.countNodePathsToRoot(nodeId);
}
return count;
};
DepGraphImpl.prototype.toJSON = function () {

@@ -136,2 +146,18 @@ var _this = this;

};
DepGraphImpl.prototype.countNodePathsToRoot = function (nodeId) {
var _this = this;
if (this._countNodePathsToRootCache.has(nodeId)) {
return this._countNodePathsToRootCache.get(nodeId);
}
var parentNodesIds = this.getNodeParentsNodeIds(nodeId);
if (parentNodesIds.length === 0) {
this._countNodePathsToRootCache.set(nodeId, 1);
return 1;
}
var count = parentNodesIds.reduce(function (acc, parentNodeId) {
return acc + _this.countNodePathsToRoot(parentNodeId);
}, 0);
this._countNodePathsToRootCache.set(nodeId, count);
return count;
};
DepGraphImpl.SCHEMA_VERSION = '1.0.0';

@@ -138,0 +164,0 @@ return DepGraphImpl;

@@ -41,2 +41,3 @@ export interface Pkg {

pkgPathsToRoot(pkg: Pkg): PkgInfo[][];
countPathsToRoot(pkg: Pkg): number;
}

@@ -43,0 +44,0 @@ export interface DepGraphInternal extends DepGraph {

2

package.json

@@ -45,3 +45,3 @@ {

},
"version": "1.1.2"
"version": "1.2.0"
}

Sorry, the diff of this file is not supported yet

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