npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

daggerlib

v1.1.1

Published

API for working with Coffman-Graham style Directed Acyclic Graphs

Downloads

21

Readme

Daggerlib.js

Daggerlib.js achieves a Coffman-Graham style directed acycled graph via a resursive set reduction algorithm. This allows for grouping the topological ordering of nodes into layers of ordinals instead of discrete ordinals. With layered ordinals, you can perform optimized parallel scheduling of tasks, render Sugiyama-style layered graphs, etc.

'use strict'
const Dagger = require('daggerlib');

// We'll create a node that has one input pin and one output pin
class MyNode extends Dagger.DaggerNode {
    constructor() {
        super();
        // Create an input pin.  We want it to be autoclone.  DaggerInputPins can only have a single
        // connection.  When an input pin is connected, and it is marked as autoclone, it will automatically 
        // generate and add a new pin to it's input pin collection.  We'll allow the pin to have a max of 4 clones.
        let inputPin = new Dagger.DaggerInputPin();
        inputPin.setAutoClone(4, "input");
        this.inputPins().addPin(inputPin, "input");

        // Create an output pin.  We want it to allow multiple connections.  A DaggerOutputPin can have unlimited
        // connections to input pins.
        let outputPin = new Dagger.DaggerOutputPin();
        outputPin.allowMultiConnect = true;
        this.outputPins().addPin(outputPin, "output");
    }
}

// create a DaggerGraph and add 4 nodes to it
let graph = new Dagger.DaggerGraph();
let n1 = new MyNode(); n1.name = "node 1"; graph.addNode(n1);
let n2 = new MyNode(); n2.name = "node 2"; graph.addNode(n2);
let n3 = new MyNode(); n3.name = "node 3"; graph.addNode(n3);
let n4 = new MyNode(); n4.name = "node 4"; graph.addNode(n4);

// connect output pin 0 of node 1 to first unconnected input put of node 2
n1.outputPins().allPins[0].connectToInput(n2.inputPins().firstUnconnectedPin);

// connect output pin 0 of node 2 to first unconnected input put of node 4
n2.outputPins().allPins[0].connectToInput(n4.inputPins().firstUnconnectedPin);

// connect output pin 0 of node 1 to first unconnected input put of node 3
n1.outputPins().allPins[0].connectToInput(n3.inputPins().firstUnconnectedPin);

// connect output pin 0 of node 3 to first unconnected input put of node 4
n3.outputPins().allPins[0].connectToInput(n4.inputPins().firstUnconnectedPin);

console.log('The graph has ' + (graph.maxOrdinal() + 1) + ' ordinals');

step1

step2

step3

step4

step5

API Reference