Socket
Socket
Sign inDemoInstall

@hapi/topo

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @hapi/topo

Topological sorting with grouping support


Version published
Weekly downloads
11M
decreased by-0.57%
Maintainers
1
Install size
60.4 kB
Created
Weekly downloads
 

Package description

What is @hapi/topo?

The @hapi/topo package is designed for managing dependencies and ordering items in a flexible way. It allows you to specify prerequisites for items and automatically sorts them based on these dependencies. This is particularly useful in scenarios where the order of operations is crucial, such as initializing plugins or tasks in a specific sequence.

What are @hapi/topo's main functionalities?

Adding items with dependencies

This feature allows you to add items to a Topo instance with specified dependencies. In the code sample, 'first' depends on 'second', so 'second' will come before 'first' in the output order.

{"const Topo = require('@hapi/topo');
const topo = new Topo();
topo.add('first', { after: ['second'], group: 'a' });
topo.add('second', { group: 'b' });
console.log(topo.nodes); // Output will be in the order of dependencies, ['second', 'first']"}

Grouping and ordering

This feature demonstrates how to group items and ensure they are processed in a specific order based on their group dependencies. Items can be added in groups and ordered relative to other groups.

{"const Topo = require('@hapi/topo');
const topo = new Topo();
topo.add(['first', 'second'], { group: 'a' });
topo.add('third', { group: 'b', after: ['a'] });
console.log(topo.nodes); // Output will respect the group order and dependencies, ['first', 'second', 'third']"}

Other packages similar to @hapi/topo

Readme

Source

@hapi/topo

Topological sorting with grouping support.

Build Status

Usage

See the API Reference

Example

const Topo = require('topo');

const morning = new Topo();

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']

Keywords

FAQs

Last updated on 11 Oct 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc