New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dependency-solver

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-solver

A tiny dependency solver using topological sorting

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
3.8K
54.01%
Maintainers
1
Weekly downloads
 
Created
Source

Dependency Solver

Build Status

A tiny dependency solver using topological sorting. Returns a list of nodes where no node comes before it's dependencies.

dep-solver

Usage

Nodes can be in any order. Any valid property name is a valid node. Circular dependencies throw an error.

var { solve } = require('dependency-solver');

var graph = {
    'A': ['B', 'C', 'F'],
    'B': ['C', 'D'],
    'F': ['E'],
    'C': ['D', 'E']
}

solve(graph);
// -> [ 'D', 'E', 'C', 'B', 'F', 'A' ]

You can also compute how many nodes depend on a particular node and dependency lines between nodes.

var { getDependedBy, getDependencyLines } = require('dependency-solver');

getDependedBy(graph);
// -> { 'B': 1, 
//      'A': 0, 
//      'C': 2, 
//      'F': 1, 
//      'D': 2, 
//      'E': 2 }

getDependencyLines(graph);
// -> [ [ 'A', 'B' ],
//      [ 'A', 'C' ],
//      [ 'A', 'F' ],
//      [ 'B', 'C' ],
//      [ 'B', 'D' ],
//      [ 'F', 'E' ],
//      [ 'C', 'D' ],
//      [ 'C', 'E' ] ]

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Keywords

dependency

FAQs

Package last updated on 21 Feb 2017

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