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

ms-dag-ts

v1.0.3

Published

Directed Acyclic Graph

Downloads

11

Readme

ms-dag-ts

Just a directed acyclic graph implementation.

Build Status

Directed Acyclic Graph

Usage

To install, run npm install ms-dag-ts.

Graph

new Graph()

Instantiates a new instance of graph.

addVertex(...uplinks: Vertex[]): Vertex

Adds a new Vertex to the graph, optionally uplinking it to the given vertices.

addEdge(top: Vertex, bottom: Vertex): Edge

Adds a new Edge to the graph, creating a downlink from top to bottom.

availableEdges(): ProtoEdge[]

Returns an array ProtoEdge objects which describe each Edge that could be connected without breaking the graph.

traverse(cb: TraversalCallback): void

Traverses the graph in order, calling cb at each Vertex.

Vertex

new Vertex(id?: number)

Instantiates a new instance of Vertex, optionally assigning it id.

id+get: number

Gets the id of this Vertex.

uplinks+get: Edge[]

Gets the array of Edge objects which describe every connection to this Vertex.

downlinks+get: Edge[]

Gets the array of Edge objects which describe every connection from this Vertex.

first+get: Vertex

Gets the first Vertex in the chain.

before+get: Vertex[]

Gets an array of Vertex objects which includes only the vertices which appear before this Vertex in the chain.

previous+get: Vertex

Gets the Vertex which appears immediately before this Vertex in the chain.

next+get: Vertex

Gets the Vertex which appears immmediately after this Vertex in the chain.

after+get: Vertex

Gets an array of Vertex objects which include only the vertices which appear after this Vertex in the chain.

last+get: Vertex

Gets the last Vertex in the chain.

remove(): Vertex

Removes this Vertex from the chain, stitching together the previous and next vertices and returning this Vertex.

insertBefore(vertex: Vertex): Vertex

Inserts the given Vertex immediately before this Vertex in the chain.

insertAfter(vertex: Vertex): Vertex

Insert the given Vertex immediately after this Vertex in the chain.

isBefore(vertex: Vertex): boolean

Returns a boolean value indicating if this Vertex is before the given Vertex in the chain.

isAfter(vertex: Vertex): boolean

Returns a boolean value indicating if this Vertex is after the given Vertex in the chain.

above(): Vertex[]

Returns an array of Vertex objects for which this Vertex is a direct or indirect downlink.

directlyAbove(): Vertex[]

Returns an array of Vertex objects for which this Vertex is a direct downlink.

isAbove(vertex: Vertex): boolean

Returns a boolean value indicating if this Vertex is a direct or indirect downlink of the given Vertex.

below(): Vertex[]

Returns an array of Vertex objects for which this Vertex is a direct or indirect uplink.

directlyBelow(): Vertex[]

Returns an array of Vertex objects for which this Vertex is a direct uplink.

isBelow(vertex: Vertex): boolean

Returns a boolean value indicating if this Vertex is a direct or indirect uplink of the given Vertex.

connectTo(vertex: Vertex, id?: number): Edge

Connects this Vertex to the given Vertex returning a new instance of Edge which defines the relationship and optionally assigning it the given id.

reflow(): void

Moves this Vertex up the chain such that it is above all of its downlinks. Calls reflow() for each uplink.

availableConnections(): ProtoEdge[]

Returns an array of ProtoEdge objects which describe every possible connection which could be made without causing a cyclic flow.