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

data-dag

v1.0.1

Published

directed acylic graph with row or column data fields

Downloads

8

Readme

data-dag

directed acylic graph with row or column data fields in under 2kb gzip, no dependencies

Example

Available in multiple module formats:

  • cjs: require('data-dag'))
  • es6: import dataDAG from 'data-dag'
  • browser: window.dataDAG
var DAG = require('data-dag') // or import DAG from 'data-dag'

function initValueSetter(name, index, array) { return array.length }

var dag = new DAG(),
		nodeCol = dag.addNData('nodeIndex', initValueSetter),
		edgeCol = dag.addEData('edgeIndex', initValueSetter)

dag.addNode('A')
dag.addNode('B')
dag.addNode('C')

dag.addEdge('D', 'A')
dag.addEdge('D', 'C')
dag.addEdge('B', 'A')
dag.addEdge('C', 'B')

console.log(dag.nData.nodeIndex.join('-')) // 1-2-3
dag.topoSort()
console.log(dag.nData.nodeIndex.join('-')) // 3-2-1

Notes and Features

  • Base case is for a column structure to easy send and receive columnar data
  • Data can still be in a row-first format by having a single column with multiple fields

API

Graph structure

  • Nodes

    • Number dag.N number of nodes
    • Object dag.getNode(nodeKey) Node {i, s, wells}
    • Number dag.addNode(nodeKey) error code or 0
    • Number dag.delNode(nodeKey) error code or 0
  • Edges

    • Number dag.E number of edges
    • Object dag.getEdge(wellNodeKey, sinkNodeKey) Edge Object {i, s, well, sink}
    • Number dag.addEdge(wellNodeKey, sinkNodeKey) error code or 0
    • Number dag.delEdge(wellNodeKey, sinkNodeKey) error code or 0
  • Data Columns

    • Number dag.addEData(name, initSetter) error code or 0
    • Number dag.addNData(name, initSetter) error code or 0
    • Number dag.delEData(name) error code or 0
    • Number dag.delNData(name) error code or 0
  • Common

    • Number dag.toposort() error code or 0 - reorders all nodes, edges and datacolunms
  • Errors

    • DAG.DONE = 0 completed, graph changed, no errors
    • DAG.EXISTS = 1 duplicate entry, no changes
    • DAG.MISSING = 2 non existing entry, nothing deleted
    • DAG.CYCLE = 3 cycle detected, no changes
    • DAG.LINKED = 4 edges must be deleted before nodes, no changes

Throws if attempting to add an edge to nodes that doesn't exist

License

MIT © Hugo Villeneuve