{"name":"graph-simple-sequencer","version":"1.0.2","description":"Sort items in a graph using a topological sort into chunks","main":"index.js","author":{"name":"James Kyle","email":"me@thejameskyle.com"},"repository":{"type":"git","url":"git+https://github.com/thejameskyle/graph-simple-sequencer.git"},"license":"MIT","keywords":["graph","adjacency","list","tasks","priority","priorities","sort","dependencies","topological","topo","sequencer"],"files":["index.js"],"scripts":{"test":"ava test.js"},"devDependencies":{"ava":"^0.24.0","flow-bin":"^0.61.0"},"gitHead":"855957caf3755bd5bc9e29db8b39d027d48d9b9d","bugs":{"url":"https://github.com/thejameskyle/graph-simple-sequencer/issues"},"homepage":"https://github.com/thejameskyle/graph-simple-sequencer#readme","_id":"graph-simple-sequencer@1.0.2","_shasum":"ebbb4093a1cce7872af05bce7f2df262a4226853","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"thejameskyle","email":"me@thejameskyle.com"},"dist":{"shasum":"ebbb4093a1cce7872af05bce7f2df262a4226853","tarball":"http://registry-npm.ywwl.com/graph-simple-sequencer/download/graph-simple-sequencer-1.0.2.tgz","integrity":"sha512-nD4pX2j089OojZ7IFSHk4xZSGhsHDva4rd3b/OWyBrB3BabdgZRdx96mYWReXIcM4GnXkgw8DdTKRwHoexA4YA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDgr765au4Q+OYNE6PqPvXMbLKoTkPDv/A61CflrQfaKAiBks6QtU9lLCiJAyX4CatOj1u0cuk01XIsEw6cnN6+mLw=="}],"size":2664,"noattachment":false,"key":"/graph-simple-sequencer/-/graph-simple-sequencer-1.0.2.tgz"},"maintainers":[{"name":"thejameskyle","email":"me@thejameskyle.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graph-simple-sequencer-1.0.2.tgz_1513918913340_0.9762259828858078"},"directories":{},"readme":"# graph-simple-sequencer\n\n> Sort items in a graph using a topological sort into chunks\n\n## Install\n\n```sh\nyarn add graph-simple-sequencer\n```\n\n## Usage\n\n```js\nimport graphSimpleSequencer from 'graph-simple-sequencer';\n\nlet graph = new Map([\n  [\"task-a\", [\"task-d\"]], // task-a depends on task-d\n  [\"task-b\", [\"task-d\", \"task-a\"]],\n  [\"task-c\", [\"task-d\"]],\n  [\"task-d\", [\"task-a\"]],\n]);\n\nlet { safe, chunks } = graphSimpleSequencer(graph);\n// { safe: false,\n//   chunks: [['task-d'], ['task-a', 'task-b', 'task-c']] }\n\nfor (let chunk of chunks) {\n  // Running tasks in parallel\n  await Promise.all(chunk.map(task => exec(task)));\n}\n```\n\n## Cycles\n\nGraph cycles are resolved by creating a new chunk with the item that has:\n\n1. The fewest number of remaining dependencies (to reduce risk of missing dependencies)\n2. The highest number of remaining dependents (to increase chance of unblocking dependents)\n","publish_time":1513918913417,"_cnpm_publish_time":1513918913417,"dist-tags":{"latest":"1.0.3"}}