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

Snyk dependency graph library

  • 1.31.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @snyk/dep-graph?

@snyk/dep-graph is an npm package that provides tools for creating, manipulating, and analyzing dependency graphs. It is particularly useful for understanding the structure of dependencies in a project, identifying vulnerabilities, and optimizing dependency management.

What are @snyk/dep-graph's main functionalities?

Creating a Dependency Graph

This feature allows you to create a dependency graph by adding nodes and dependencies between them. The code sample demonstrates how to create a simple dependency graph with a root package and two dependencies.

const { DepGraph } = require('@snyk/dep-graph');

const depGraph = new DepGraph();
depGraph.addNode('root', { name: 'root-package', version: '1.0.0' });
depGraph.addNode('dep1', { name: 'dependency1', version: '1.0.0' });
depGraph.addNode('dep2', { name: 'dependency2', version: '2.0.0' });
depGraph.addDependency('root', 'dep1');
depGraph.addDependency('root', 'dep2');
console.log(depGraph.toJSON());

Analyzing a Dependency Graph

This feature allows you to analyze the dependency graph by retrieving all the packages in the graph. The code sample demonstrates how to get all the dependencies of the root package.

const { DepGraph } = require('@snyk/dep-graph');

const depGraph = new DepGraph();
depGraph.addNode('root', { name: 'root-package', version: '1.0.0' });
depGraph.addNode('dep1', { name: 'dependency1', version: '1.0.0' });
depGraph.addNode('dep2', { name: 'dependency2', version: '2.0.0' });
depGraph.addDependency('root', 'dep1');
depGraph.addDependency('root', 'dep2');

const allDeps = depGraph.getDepPkgs();
console.log(allDeps);

Visualizing a Dependency Graph

This feature allows you to visualize the dependency graph using Graphviz. The code sample demonstrates how to render the dependency graph to a Graphviz format.

const { DepGraph } = require('@snyk/dep-graph');
const { renderGraph } = require('@snyk/dep-graph/dist/graphviz');

const depGraph = new DepGraph();
depGraph.addNode('root', { name: 'root-package', version: '1.0.0' });
depGraph.addNode('dep1', { name: 'dependency1', version: '1.0.0' });
depGraph.addNode('dep2', { name: 'dependency2', version: '2.0.0' });
depGraph.addDependency('root', 'dep1');
depGraph.addDependency('root', 'dep2');

const graphviz = renderGraph(depGraph);
console.log(graphviz);

Other packages similar to @snyk/dep-graph

FAQs

Package last updated on 30 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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