JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 977316
  • Score
    100M100P100Q36487F
  • License BSD-3-Clause

Topological sorting with grouping support

Package Exports

  • topo

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (topo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

topo

Topological sorting with grouping support.

Build Status

Lead Maintainer: Devin Ivy

Usage

var Topo = require('topo');

var topo = new Topo();

topo.add('Nap', { after: ['breakfast', 'prep'] });

topo.add([
    'Make toast',
    'Pour juice'
], { before: 'breakfast', group: 'prep' });

topo.add('Eat breakfast', { group: 'breakfast' });

topo.nodes;        // ['Make toast', 'Pour juice', 'Eat breakfast', 'Nap']

Topo

The Topo object is the container for topologically sorting a list of nodes with non-circular interdependencies.

new Topo()

Creates a new Topo object.

topo.add(nodes, [options])

Specifies an additional node or list of nodes to be topologically sorted where:

  • nodes - a mixed value or array of mixed values to be added as nodes to the topologically sorted list.
  • options - optional sorting information about the nodes:
    • group - a string naming the group to which nodes should be assigned. The group name '?' is reserved.
    • before - a string or array of strings specifying the groups that nodes must precede in the topological sort.
    • after - a string or array of strings specifying the groups that nodes must succeed in the topological sort.

Returns an array of the topologically sorted nodes.

topo.nodes

An array of the topologically sorted nodes. This list is renewed upon each call to topo.add().