topo

Topological sorting with grouping support.

Latest Version: 6.0.2
hapi-family
Installation:

npm: npm install @hapi/topo

yarn: yarn add @hapi/topo

Module Status:
Version License Node Dependencies CI
6.0.2
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status
5.1.0
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status

Introduction

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

Example

const Topo = require('@hapi/topo');

const morning = new Topo.Sorter();

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

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

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

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