Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 29, 2024 via pnpm

toposort 2.0.2

Topological sort of directed ascyclic graphs (like dependecy lists)
Package summary
Share
0
issues
1
license
1
MIT
Package created
2 Nov 2012
Version published
28 Apr 2018
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
toposort@2.0.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of toposort 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does toposort do?

Toposort is an incredibly useful npm package that performs a topological sort on directed acyclic graphs. This makes Toposort perfect for sorting things like dependency lists. By arranging nodes in such a way that every edge is directed from an earlier node to a later one, it provides a legal execution order, which is particularly valuable in scenarios such as package and task dependencies, order processing, data serialization, and more.

How do you use toposort?

To use Toposort, you'll first need to install it using npm by running the command npm install toposort. Once installed, you can require it at the beginning of your JavaScript file like so:

var toposort = require('toposort');

After that, you can use it to sort your graph. For example, consider you have the following tasks and their dependencies:

var graph = [
  ['put on your shoes', 'tie your shoes'],
  ['put on your shirt', 'put on your jacket'],
  ['put on your shorts', 'put on your jacket'],
  ['put on your shorts', 'put on your shoes']
]

You sort these tasks using Toposort like so:

toposort(graph)

The above code will provide an output like this, which is the order that the tasks should be executed:

[
 'put on your shirt',
 'put on your shorts',
 'put on your jacket',
 'put on your shoes',
 'tie your shoes'
]

For sorting dependencies, you can use the toposort.array(nodes, edges) method:

var graph = [
  ['tie your shoes', 'put on your shoes'],
  ['put on your jacket', 'put on your shirt'],
  ['put on your shoes', 'put on your shorts'],
  ['put on your jacket', 'put on your shorts']
]

toposort(graph).reverse() 

The output will be a legal execution order based on the dependencies defined.

Where are the toposort docs?

Documentation for Toposort and its API is available directly in the README file at its GitHub repository. The URL for the repository is git+https://github.com/marcelklehr/toposort.git. The README provides a thorough guide on how to install and use Toposort, its methods, usage examples, and more. Learn and get started with Toposort, the powerful tool for sorting directed acyclic graphs in a snap!