JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 517070
  • Score
    100M100P100Q177004F
  • License MIT

A map of key/value pairs that can be traversed in topological order

Package Exports

  • dag-map

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dag-map) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dag-map Build Status

An ordered map of key/value pairs and a simple API for adding contraints (directed and acyclic) which provides a way of iterating key/value pairs in topological order.

Used for ordering initializers in Ember. Has a flexible constraint syntax that can add before/after contraints that can forward reference things yet to be added.

API

import DAG from 'dag-map';

let map = new DAG();

// map a key value pair
map.add('eat', 'Eat Dinner');
// add a key value pair with before and after constraints
map.add('serve', 'Serve the food', 'eat', 'set');
// keys can be added after a key has been referenced
map.add('set', 'Set the table');

// graph now is eat -> serve -> set

// constraints can be an array
map.add('cook', 'Cook the roast and veggies', 'serve', ['prep', 'buy']);

map.add('wash', 'Wash the veggies', 'prep', 'buy');
map.add('buy', 'Buy roast and veggies');
map.add('prep', 'Prep veggies', undefined, 'wash');

// log in order (multi valid spots for set the table).
map.topsort((key, val) => console.log(key, val));
// set Set the table
// buy Buy roast and veggies
// wash Wash the veggies
// prep Prep veggies
// cook Cook the roast and veggies
// serve Serve the food
// eat Eat Dinner

Developing

  • npm install
  • npm test runs the tests headless
  • npm run build rebuild