{"_id":"graph-run","_rev":"6-6827b7427d9b25c9303916a55e2c77b1","name":"graph-run","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"graph-run","version":"1.0.0","keywords":["graph","async","parallel","topological","topological sort"],"author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"graph-run@1.0.0","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/isaacs/graph-run#readme","bugs":{"url":"https://github.com/isaacs/graph-run/issues"},"dist":{"shasum":"86b9c6baa068d9915e6577b73430cb94cb0781b4","tarball":"https://registry.npmjs.org/graph-run/-/graph-run-1.0.0.tgz","fileCount":13,"integrity":"sha512-Gr7pNr5SSYgPeBWbprp9eMjHhr7ytovAmwWti+wkP55teg9UgK5i2OAavtxaD87P5SAAtludXr/5WuO6BdB0NQ==","signatures":[{"sig":"MEYCIQDJPEIDvygX1PYTB5cNk1nU5BxGoDcgut04LlAbRz0NIAIhAILZgnQX4JfCo3VdidaCM448o02KyPOVUyF5sNthMEAC","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":130882},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"f55181896f3c4a17dc5abec4b8d700cc034fc65f","scripts":{"snap":"tap","test":"tap","format":"prettier --write . --log-level warn --cache","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":70,"arrowParens":"avoid","singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"experimentalTernaries":true},"repository":{"url":"git+https://github.com/isaacs/graph-run.git","type":"git"},"_npmVersion":"10.7.0","description":"Run operations on a graph, maximizing parallelism","directories":{},"_nodeVersion":"20.13.1","_hasShrinkwrap":false,"devDependencies":{"tap":"^19.0.2","tshy":"^1.14.0","typedoc":"^0.25.13","prettier":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/graph-run_1.0.0_1716769979997_0.6407955234552372","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"graph-run","version":"1.0.1","keywords":["graph","async","parallel","topological","topological sort"],"author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"graph-run@1.0.1","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/isaacs/graph-run#readme","bugs":{"url":"https://github.com/isaacs/graph-run/issues"},"dist":{"shasum":"b37baa74a2dc2fa0f15f9fd2eb8cdca078934336","tarball":"https://registry.npmjs.org/graph-run/-/graph-run-1.0.1.tgz","fileCount":13,"integrity":"sha512-pkffZoYI5q6uqhhSpXOgEdF+bAkrRLTY8q5T60OEnfWMKkinpHcGZSpKdzNLbBv+m1QOX/Dsp0uyheeUQN8b7g==","signatures":[{"sig":"MEYCIQCFUFCYn37cNQusaFqljhSDfhCLfwKkG+6ovB2P3FN0YwIhAOzaXBTlGyavNU0iinGznUuSOZ/5LBNysYrVlMilZeHM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":130938},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"bdf2af33e4853494d95b8941648931039c296f07","scripts":{"snap":"tap","test":"tap","format":"prettier --write . --log-level warn --cache","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":70,"arrowParens":"avoid","singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"experimentalTernaries":true},"repository":{"url":"git+https://github.com/isaacs/graph-run.git","type":"git"},"_npmVersion":"10.7.0","description":"Run operations on a graph, maximizing parallelism","directories":{},"_nodeVersion":"20.13.1","_hasShrinkwrap":false,"devDependencies":{"tap":"^19.0.2","tshy":"^1.14.0","typedoc":"^0.25.13","prettier":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/graph-run_1.0.1_1716770945531_0.4775293335435169","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"graph-run","version":"1.0.2","keywords":["graph","async","parallel","topological","topological sort"],"author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"graph-run@1.0.2","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/isaacs/graph-run#readme","bugs":{"url":"https://github.com/isaacs/graph-run/issues"},"dist":{"shasum":"e9c746f4cd674fc745bac42f63e2fdc3be540aef","tarball":"https://registry.npmjs.org/graph-run/-/graph-run-1.0.2.tgz","fileCount":13,"integrity":"sha512-q3HYpDgZvdkI1qnLEiov/6BXBjujOnzNw3N9fjOilYCtTmeKSzOrjA2F9i4uCI0jyAI6AKaLw+XZZ9bg85kJhw==","signatures":[{"sig":"MEYCIQDzy1FY59pWjdotQqfzC9qI40cZvOeCvlGQqVwjwwATowIhAJIkIpjC24KANtiFH1cSX3yhdpbfjZDILR5F4eZGyFIw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":112336},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"58f5fd5c7005dd5361942067acb75c54abe6ad3d","scripts":{"snap":"tap","test":"tap","format":"prettier --write . --log-level warn --cache","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":70,"arrowParens":"avoid","singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"experimentalTernaries":true},"repository":{"url":"git+https://github.com/isaacs/graph-run.git","type":"git"},"_npmVersion":"10.7.0","description":"Run operations on a graph, maximizing parallelism","directories":{},"_nodeVersion":"20.13.1","_hasShrinkwrap":false,"devDependencies":{"tap":"^19.0.2","tshy":"^1.14.0","typedoc":"^0.25.13","prettier":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/graph-run_1.0.2_1716781408575_0.7547684205695737","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"graph-run","version":"1.0.3","keywords":["graph","async","parallel","topological","topological sort"],"author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"graph-run@1.0.3","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/isaacs/graph-run#readme","bugs":{"url":"https://github.com/isaacs/graph-run/issues"},"dist":{"shasum":"c8516d676f7d3b8751612599c446ae16bc51cebf","tarball":"https://registry.npmjs.org/graph-run/-/graph-run-1.0.3.tgz","fileCount":13,"integrity":"sha512-NCETWIYbXqWhfDOJYitj4VZzkvuSPxOJZF/Sxu/OUWzjXj1iRDGPlImA2XfBbZgLDOwAMti8JN2o0IGQVPWhjw==","signatures":[{"sig":"MEUCIQDZG2URXn2+lysXtgMm9WAN/T9f5KMAzMO7t+hzTkxzYQIgW5tw88cTe8+Jhr6+ksI37wPfLk4tbEQkBVsAd0gg6Wc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":113254},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"7f09be938344dd9a9f7187f66a3ee17cc2a69cf1","scripts":{"snap":"tap","test":"tap","format":"prettier --write . --log-level warn --cache","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":70,"arrowParens":"avoid","singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"experimentalTernaries":true},"repository":{"url":"git+https://github.com/isaacs/graph-run.git","type":"git"},"_npmVersion":"10.7.0","description":"Run operations on a graph, maximizing parallelism","directories":{},"_nodeVersion":"20.13.1","_hasShrinkwrap":false,"devDependencies":{"tap":"^19.0.2","tshy":"^1.14.0","typedoc":"^0.25.13","prettier":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/graph-run_1.0.3_1717265413771_0.33835712137359675","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"graph-run","version":"1.0.4","keywords":["graph","async","parallel","topological","topological sort"],"author":{"url":"https://izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"graph-run@1.0.4","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/isaacs/graph-run#readme","bugs":{"url":"https://github.com/isaacs/graph-run/issues"},"dist":{"shasum":"0c80f360256b5e310a6940f590912865d9a0ba94","tarball":"https://registry.npmjs.org/graph-run/-/graph-run-1.0.4.tgz","fileCount":13,"integrity":"sha512-QCT8ovkn5v+rJh88hvxnPEhA+L/jKnZCMm+TVVOVRKotQS2KJPM2UfChh1Pj+/EhcAG3SkIzqFPzFnn6o1yLNg==","signatures":[{"sig":"MEUCIDyziEhQJSjmgdUTV1NzkIlYFGnyPLOejZdXfwqCgU1/AiEAguQvxrnkycD/XHw08Ceukrrrwo6RWH2BtMOfcriCLao=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":116072},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"5bff2e941fb632f4577d64cdb94349fb6279b395","scripts":{"snap":"tap","test":"tap","format":"prettier --write . --log-level warn --cache","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":70,"arrowParens":"avoid","singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"experimentalTernaries":true},"repository":{"url":"git+https://github.com/isaacs/graph-run.git","type":"git"},"_npmVersion":"10.7.0","description":"Run operations on a graph, maximizing parallelism","directories":{},"_nodeVersion":"20.13.1","_hasShrinkwrap":false,"devDependencies":{"tap":"^21.0.1","tshy":"^3.0.2","typedoc":"^0.26.7","prettier":"^3.3.3"},"_npmOperationalInternal":{"tmp":"tmp/graph-run_1.0.4_1726083506403_0.345681846868404","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"graph-run","version":"1.1.0","description":"Run operations on a graph, maximizing parallelism","main":"./dist/commonjs/index.js","exports":{"./package.json":"./package.json",".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"scripts":{"preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","prepare":"tshy","pretest":"npm run prepare","presnap":"npm run prepare","test":"tap","snap":"tap","format":"prettier --write . --log-level warn --cache","typedoc":"typedoc"},"keywords":["graph","async","parallel","topological","topological sort"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"BlueOak-1.0.0","repository":{"type":"git","url":"git+https://github.com/isaacs/graph-run.git"},"devDependencies":{"@types/node":"^22.5.4","prettier":"^3.3.3","tap":"^21.0.1","tshy":"^3.0.2","typedoc":"^0.26.7"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf","experimentalTernaries":true},"tshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts"}},"types":"./dist/commonjs/index.d.ts","type":"module","module":"./dist/esm/index.js","_id":"graph-run@1.1.0","gitHead":"0ab3d026640d0d29d3cb0551316b06b2975736e0","bugs":{"url":"https://github.com/isaacs/graph-run/issues"},"homepage":"https://github.com/isaacs/graph-run#readme","_nodeVersion":"22.14.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-L7Lis9kQWoh3A7QFZOzWlim61h4Suvu28txLaiuRBvQQia6zTx4Q32R9E2VTfpcI6VFfJlMcxXdxt7SItaeb1A==","shasum":"e6e0c77420b5f1428f206953203889d70c8136c7","tarball":"https://registry.npmjs.org/graph-run/-/graph-run-1.1.0.tgz","fileCount":13,"unpackedSize":124921,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEiGxNhL9umH0LT6pRNJIWBmOdwpMUbF04mMhQotaRSfAiEA19UqayTYDZjNYkTcS11sTg+dOc/49DgjI92VtCyOcgA="}]},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/graph-run_1.1.0_1748544886853_0.7427978693165875"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-27T00:32:59.922Z","modified":"2025-05-29T18:54:47.289Z","1.0.0":"2024-05-27T00:33:00.164Z","1.0.1":"2024-05-27T00:49:05.683Z","1.0.2":"2024-05-27T03:43:28.741Z","1.0.3":"2024-06-01T18:10:13.923Z","1.0.4":"2024-09-11T19:38:26.647Z","1.1.0":"2025-05-29T18:54:47.122Z"},"bugs":{"url":"https://github.com/isaacs/graph-run/issues"},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"BlueOak-1.0.0","homepage":"https://github.com/isaacs/graph-run#readme","keywords":["graph","async","parallel","topological","topological sort"],"repository":{"type":"git","url":"git+https://github.com/isaacs/graph-run.git"},"description":"Run operations on a graph, maximizing parallelism","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"readme":"# graph-run\n\nFigure out which items in a dependency graph can be handled in\nparallel, and which must be deferred until their dependencies are\ncompleted. Handles cyclic and acyclic graphs, but if cycles are\nallowed, then dependency order may not be guaranteed.\n\nFor example, given the following directed graph:\n\n```mermaid\nflowchart TD\n    A --> B\n    A --> C\n    B --> E\n    B --> D\n    C --> D\n    C --> G\n    D --> F\n    F --> E\n```\n\nit will allow you to operate in this order:\n\n- E and G in parallel (since they are leaf nodes)\n- F when E is complete\n- D when F is complete\n- B when D and E are complete (possibly in parallel with C)\n- C when D and G are complete (possibly in parallel with B)\n- A when B and C are complete\n\nOperation will be maximally parallelized, so that each step in\nthe graph only waits until its dependencies are completed.\n\n## Cycles\n\nIf a cycle exists in the graph, then at least one node in the\ncycle will by necessity be operated upon _before_ its\ndependencies are complete.\n\nCycles may be disallowed by throwing in the `onCycle` method\nprovided.\n\n## Contract\n\n- Each node reachable from the initial entry points provided will\n  be visited exactly once.\n- Except in the case of cycles, each node's dependencies will be\n  visited before itself.\n- In the default async forms of the methods provided:\n  - All methods will be awaited before continuing.\n  - Any operations that can be done in parallel will be.\n- All pending visits and dependency lookups will be skipped if a\n  provided `AbortSignal` fires.\n\n## Difference between this and typical topological sort\n\nThis is not just a topological sort, and there are better\nlibraries available that implement Kahn's Topological Sort very\nefficiently.\n\nHowever, topological sorting is insufficient if you wish to know\nwhich items can be operated on _in parallel_, and Kahn's\nalgorithm only works when the graph is guaranteed to be acyclic\nand all nodes are known ahead of time.\n\nThis implementation does not require that the graph be entirely\nloaded ahead of time, and provides a mechanism to treat cycles as\na warning rather than an error, with the caveat that if cycles\nare allowed then topological ordering is of course not\nguaranteed.\n\n## Caveat\n\nWhile this _can_ be used in theory to explore any infinitely large\ngraph, note that the result set will be stored in memory.\n\nSo, if you were to use it to try to crawl all the links in\nWikipedia or something, you're going to have a Bad Time if the\nresult set gets too big.\n\n## USAGE\n\n```js\nimport {\n  // returns Promise<Map<Node, Result>>\n  graphRun,\n  // returns Promise<Map<Node, PromiseSettledResult<Result>>>\n  // like Promise.allSettled\n  // Implies failFast:false\n  allSettled,\n  // resolves to first successful result, or rejects with AggregateError\n  // like Promise.any()\n  any,\n  // returns or rejects on the first visit to complete\n  // like Promise.race()\n  race,\n\n  // options provided to sync methods MUST be sychronous\n\n  // returns Map<Node, Result>\n  graphRunSync,\n  // returns Map<Node, PromiseSettledResult<Result>>\n  allSettledSync,\n  // returns first successful result, or throws AggregateError\n  anySync,\n  // returns or throws on the first visit\n  // this is somewhat useless, since you can just call the method\n  // on the first node in the options.graph list, but is included\n  // for symmetry reasons.\n  raceSync,\n} from 'graph-run'\n\n// optionally used to trigger an abort of the walk at any time\nconst ac = new AbortController()\n\n// return value will be a Promise<Map<Node, Result>>\n// when using allSettled, returns Promise<Map<Node, PromiseSettledResult>>\nconst results = await graphRun/*<Node, Result>*/({\n  // provide one or more node to serve as entry points.\n  // this MAY be the entire graph, but doesn't have to be.\n  // Node[]\n  graph: [some, nodes, known, at, the, start],\n\n  // a sync or async method for providing nodes that are\n  // dependents of the node being considered.\n  // Return [] if node has no dependencies.\n  // (n: Node) => Node[] | Promise<Node[]>\n  getDeps: async (n) => {\n    // if a promise is returned, then it must resolve to an\n    // array of nodes.\n    return [the, dependency, node, objects]\n  },\n\n  // sync or async method that will be executed on each node in the graph\n  // node is the data object being operated on, signal is an\n  // AbortSignal that will fire if the operation should halt.\n  // (node: Node, signal: AbortSignal, path: Node[]) => Result|Promise<Result>\n  visit: async (node, signal, path) => {\n    await doSomething(n)\n  },\n\n  // optional: if this method throws, then the traversal will\n  // of course fail when cycles are encountered. If not provided,\n  // then cycles are silently detected and skipped.\n  // first argument is the dependency that would cause a cycle\n  // second argument is the cycle from that node back to itself\n  // third is the path to the dependent that wanted to load it,\n  // but instead will skip it because of the cycle.\n  // (node: Node, cycle: Node[], path: Node[]) => void | Promise<void>\n  onCycle: (node, cycle, path) => {\n    console.error(\n      `warning: while evaluating ${\n        node\n      } at path ${\n        path.join('->')\n      } encountered cycle: ${\n        cycle.join('->')\n      }. Proceeding without this dependency.`\n    )\n  },\n\n  // Whether to abort the entire traversal on the first error\n  // if true, then this will reject with an error and trigger an abort\n  // on all in-progress operations.\n  // if false, then the rejection value will be an AggregateError of all\n  // failures encountered. (For consistency, an AggregateError is\n  // raised if failFast is false, even if only one failure is countered.)\n  // default: true\n  failFast: true\n\n  // Optional: pass along a signal that you can use externally to signal\n  // the graph traversal should end prematurely.\n  signal: ac.signal\n})\n\n// Another example, detect whether it's a directed acyclic graph:\nconst isDAG = (graph) => {\n  try {\n    graphRunSync({\n      graph: [graph],\n      getDeps: n => n.children ?? [],\n      onCycle: () => { throw 'cycle detected' },\n      visit: () => {}\n    })\n    return true\n  } catch {\n    return false\n  }\n}\n\nconst g = {\n  children: [\n    {\n      name: 'a',\n      children: [{ name: 'b' }],\n    }\n  ]\n}\nconsole.log(isDAG(g)) // true\n// create a cycle\ng.children[0].children[0].children = g.children\nconsole.log(isDAG(g)) // false\n```\n\nSee [the typedocs](https://isaacs.github.com/graph-run) for\ncomplete API details.\n\n## Other Options\n\n- [topological-sort](https://www.npmjs.com/package/topological-sort)\n- [@hapi/topo](https://www.npmjs.com/package/@hapi/topo)\n- [toposort](https://www.npmjs.com/package/toposort)\n- [graph-data-structure](https://www.npmjs.com/package/graph-data-structure)\n- [js-graph-algorithms](https://www.npmjs.com/package/js-graph-algorithms)\n- [fast-graph](https://www.npmjs.com/package/fast-graph)\n- [treeverse](https://www.npmjs.com/package/treeverse)\n\n## How This Is Different\n\n- More flexible than most as far as the data structures used. Ie,\n  `Node` can be any value type.\n- Dependency edges are resolved on-demand, and may be calculated\n  asynchronously, making it efficient in cases where loading the\n  entire graph may be expensive.\n- Both cyclic and acyclic graphs are supported.\n","readmeFilename":"README.md"}