{
  "_args": [
    [
      {
        "raw": "graph-sequencer@2.0.0",
        "scope": null,
        "escapedName": "graph-sequencer",
        "name": "graph-sequencer",
        "rawSpec": "2.0.0",
        "spec": "2.0.0",
        "type": "version"
      },
      "/home/zkochan/src/pnpm/packages/pnpm"
    ]
  ],
  "_from": "graph-sequencer@2.0.0",
  "_id": "graph-sequencer@2.0.0",
  "_inCache": true,
  "_location": "/graph-sequencer",
  "_nodeVersion": "4.8.4",
  "_npmOperationalInternal": {
    "host": "s3://npm-registry-packages",
    "tmp": "tmp/graph-sequencer-2.0.0.tgz_1512612570792_0.28757167397998273"
  },
  "_npmUser": {
    "name": "thejameskyle",
    "email": "me@thejameskyle.com"
  },
  "_npmVersion": "2.15.11",
  "_phantomChildren": {},
  "_requested": {
    "raw": "graph-sequencer@2.0.0",
    "scope": null,
    "escapedName": "graph-sequencer",
    "name": "graph-sequencer",
    "rawSpec": "2.0.0",
    "spec": "2.0.0",
    "type": "version"
  },
  "_requiredBy": [
    "/",
    "/@pnpm/headless",
    "/supi"
  ],
  "_resolved": "https://registry.npmjs.org/graph-sequencer/-/graph-sequencer-2.0.0.tgz",
  "_shasum": "bfb809b8af584f6f5287cdce507a30d4aea6ee70",
  "_shrinkwrap": null,
  "_spec": "graph-sequencer@2.0.0",
  "_where": "/home/zkochan/src/pnpm/packages/pnpm",
  "author": {
    "name": "James Kyle",
    "email": "me@thejameskyle.com"
  },
  "bugs": {
    "url": "https://github.com/thejameskyle/graph-sequencer/issues"
  },
  "dependencies": {
    "array-flatten": "^2.1.1",
    "array-includes": "^3.0.3"
  },
  "description": "Sort items in a graph using a topological sort while resolving cycles with priority groups",
  "devDependencies": {
    "ava": "^0.24.0",
    "flow-bin": "^0.60.1"
  },
  "directories": {},
  "dist": {
    "shasum": "bfb809b8af584f6f5287cdce507a30d4aea6ee70",
    "tarball": "https://registry.npmjs.org/graph-sequencer/-/graph-sequencer-2.0.0.tgz"
  },
  "files": [
    "index.js"
  ],
  "gitHead": "565c024a02a1e3b83758149a2fd4eeb24753a898",
  "homepage": "https://github.com/thejameskyle/graph-sequencer#readme",
  "keywords": [
    "graph",
    "adjacency",
    "list",
    "tasks",
    "priority",
    "priorities",
    "sort",
    "dependencies",
    "topological",
    "topo",
    "sequencer"
  ],
  "license": "MIT",
  "main": "index.js",
  "maintainers": [
    {
      "name": "thejameskyle",
      "email": "me@thejameskyle.com"
    }
  ],
  "name": "graph-sequencer",
  "optionalDependencies": {},
  "readme": "# graph-sequencer\n\n> Sort items in a graph using a topological sort while resolving cycles with\n> priority groups.\n\nSay you have some sort of graph of dependencies: (using an adjacency list)\n\n```js\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```\n\nYou could run a topological sort on these items, but you'd still end up with\ncycles:\n\n```\ntask-a -> task-d -> task-a\n```\n\nTo resolve this you pass \"priority groups\" to `graph-sequencer`:\n\n```js\nlet groups = [\n  [\"task-d\"], // higher priority\n  [\"task-a\", \"task-b\", \"task-c\"], // lower priority\n];\n```\n\nThe result will be a chunked list of items sorted topologically and by the\npriority groups:\n\n```js\nlet chunks = [\n  [\"task-d\"],\n  [\"task-a\", \"task-c\"],\n  [\"task-b\"]\n];\n```\n\nYou can then run all these items in order with maximum concurrency:\n\n```js\nfor (let chunk of chunks) {\n  await Promise.all(chunk.map(task => exec(task)));\n}\n```\n\nHowever, even with priority groups you can still accidentally create cycles of\ndependencies in your graph.\n\n`graph-sequencer` will return a list of the unresolved cycles:\n\n```js\nlet cycles = [\n  [\"task-a\", \"task-b\"] // task-a depends on task-b which depends on task-a\n];\n```\n\nHowever, `graph-sequencer` will still return an \"unsafe\" set of chunks. When it\ncomes across a cycle, it will add another chunk with the item with the fewest\ndependencies remaining which will often break cycles.\n\n\nAll together that looks like this:\n\n```js\nconst graphSequencer = require('graph-sequencer');\n\ngraphSequencer({\n  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  groups: [\n    [\"task-d\"], // higher priority\n    [\"task-a\", \"task-b\", \"task-c\"], // lower priority\n  ],\n})\n// {\n//   safe: true,\n//   chunks: [[\"task-d\"], [\"task-a\", \"task-c\"], [\"task-b\"]],\n//   cycles: [],\n// }\n```\n",
  "readmeFilename": "README.md",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/thejameskyle/graph-sequencer.git"
  },
  "scripts": {
    "test": "ava test.js"
  },
  "version": "2.0.0"
}
