{"name":"graph-simple-sequencer","version":"1.0.3","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"},"dependencies":{"array-includes":"^3.0.3"},"gitHead":"76cb4ff21cd8d74fa42d02240ea4517b8eb86725","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.3","_shasum":"80e040ba3ca3b44cffb1b3db8afa6484166982fc","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.4","_npmUser":{"name":"thejameskyle","email":"me@thejameskyle.com"},"dist":{"shasum":"80e040ba3ca3b44cffb1b3db8afa6484166982fc","tarball":"http://registry-npm.ywwl.com/graph-simple-sequencer/download/graph-simple-sequencer-1.0.3.tgz","integrity":"sha512-Yg43YTKFNbr9H8LUMoQeR50WiSufspJNd0y81sKgxR9VxGthRYpWxKRcKLRwuHIV0Cjn7moGqKSJyV1Z8beNMA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4HR3FX5KsjZP6De+wlg4k+Q51vAIlMoOSN/nwMDLKgQIhAI7SLtHeECKDNHEEPY1ryk2MUJNVcsxzjLmer5OOv5dv"}],"size":2697,"noattachment":false,"key":"/graph-simple-sequencer/-/graph-simple-sequencer-1.0.3.tgz"},"maintainers":[{"name":"thejameskyle","email":"me@thejameskyle.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graph-simple-sequencer-1.0.3.tgz_1513919416101_0.41625158465467393"},"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":1513919416182,"_cnpm_publish_time":1513919416182,"dist-tags":{"latest":"1.0.3"}}