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

@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.26.0 to 1.27.0

dist/legacy/cycles.d.ts

42

dist/legacy/index.js

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

const objectHash = require("object-hash");
const cycles_1 = require("./cycles");
const memiozation_1 = require("./memiozation");
function addLabel(dep, key, value) {

@@ -144,7 +146,3 @@ if (!dep.labels) {

const depGraph = depGraphInterface;
// TODO: implement cycles support
if (depGraph.hasCycles()) {
throw new Error('Conversion to DepTree does not support cyclic graphs yet');
}
const depTree = await buildSubtree(depGraph, depGraph.rootNodeId, opts.deduplicateWithinTopLevelDeps ? null : false);
const [depTree] = await buildSubtree(depGraph, depGraph.rootNodeId, opts.deduplicateWithinTopLevelDeps ? null : false);
depTree.type = depGraph.pkgManager.name;

@@ -180,5 +178,8 @@ depTree.packageFormatVersion = constructPackageFormatVersion(pkgType);

async function buildSubtree(depGraph, nodeId, maybeDeduplicationSet = false, // false = disabled; null = not in deduplication scope yet
memoizationMap = new Map()) {
if (!maybeDeduplicationSet && memoizationMap.has(nodeId)) {
return memoizationMap.get(nodeId);
ancestors = [], memoizationMap = new Map()) {
if (!maybeDeduplicationSet) {
const memoizedDepTree = memiozation_1.getMemoizedDepTree(nodeId, ancestors, memoizationMap);
if (memoizedDepTree) {
return [memoizedDepTree, undefined];
}
}

@@ -199,5 +200,11 @@ const isRoot = nodeId === depGraph.rootNodeId;

if (!depInstanceIds || depInstanceIds.length === 0) {
memoizationMap.set(nodeId, depTree);
return depTree;
memoizationMap.set(nodeId, { depTree });
return [depTree, undefined];
}
const cycle = cycles_1.getCycle(ancestors, nodeId);
if (cycle) {
// This node starts a cycle and now it's the second visit.
addLabel(depTree, 'pruned', 'cyclic');
return [depTree, [cycle]];
}
if (maybeDeduplicationSet) {

@@ -208,6 +215,7 @@ if (maybeDeduplicationSet.has(nodeId)) {

}
return depTree;
return [depTree, undefined];
}
maybeDeduplicationSet.add(nodeId);
}
const cycles = [];
for (const depInstId of depInstanceIds) {

@@ -219,3 +227,8 @@ // Deduplication of nodes occurs only within a scope of a top-level dependency.

}
const subtree = await buildSubtree(depGraph, depInstId, maybeDeduplicationSet, memoizationMap);
const [subtree, subtreeCycles] = await buildSubtree(depGraph, depInstId, maybeDeduplicationSet, ancestors.concat(nodeId), memoizationMap);
if (subtreeCycles) {
for (const cycle of subtreeCycles) {
cycles.push(cycle);
}
}
if (!subtree) {

@@ -232,4 +245,5 @@ continue;

}
memoizationMap.set(nodeId, depTree);
return depTree;
const partitionedCycles = cycles_1.partitionCycles(nodeId, cycles);
memiozation_1.memoize(nodeId, memoizationMap, depTree, partitionedCycles);
return [depTree, partitionedCycles.cyclesWithThisNode];
}

@@ -236,0 +250,0 @@ function trimAfterLastSep(str, sep) {

@@ -71,3 +71,3 @@ {

},
"version": "1.26.0"
"version": "1.27.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