{"name":"toposort-class","version":"1.0.0","description":"Topological sort of directed acyclic graphs (like dependecy lists)","main":"./index.js","devDependencies":{"babel-eslint":"^4.0.5","eslint":"^0.24.1","grunt":"^0.4.5","grunt-babel":"^5.0.1","grunt-banner":"^0.4.0","grunt-contrib-clean":"^0.6.0","grunt-contrib-uglify":"^0.9.1","matcha":"^0.6.0","mocha":"^2.2.5"},"scripts":{"test":"mocha -b test","eslint":"eslint src/toposort.js test/spec.js Gruntfile.js","benchmark":"matcha benchmark/general.js","benchmark-save":"matcha -R csv benchmark/general.js > benchmark/results.csv"},"repository":{"type":"git","url":"git+https://github.com/gustavohenke/toposort.git"},"keywords":["topological","sort","sorting","graphs","graph","dependency","list","dependencies","acyclic","browser"],"author":"","license":"MIT","gitHead":"fcb4642302b9d38a962990a092ae73282cdcb5a9","bugs":{"url":"https://github.com/gustavohenke/toposort/issues"},"homepage":"https://github.com/gustavohenke/toposort#readme","_id":"toposort-class@1.0.0","_shasum":"b4d3e5457782d8dbca8274fc454e9f8b49e8def1","_from":".","_npmVersion":"2.13.0","_nodeVersion":"2.3.3","_npmUser":{"name":"gustavohenke","email":"gustavo@injoin.io"},"maintainers":[{"name":"gustavohenke","email":"gustavo@injoin.com.br"}],"dist":{"shasum":"b4d3e5457782d8dbca8274fc454e9f8b49e8def1","tarball":"http://registry-npm.ywwl.com/toposort-class/download/toposort-class-1.0.0.tgz","integrity":"sha512-MrG7E4cwAgSa9pzjbFNxw7xILxPWNcR1ic/l6DBSnhuFGKZrPVYrKNeSMyitzTXvrUBuEtu2XngZld4DdLgyxA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCI2g9tj7xoaXr1zJZW//B7bFNqcvfYaPPrp2su5cr3MAIgPISeSZ4anulbv/KA2K2DaYxmsTzZxOqQA11O5IzWIG0="}],"size":7180,"noattachment":false,"key":"/toposort-class/-/toposort-class-1.0.0.tgz"},"directories":{},"readme":"# Toposort\n[![Build Status](http://img.shields.io/travis/gustavohenke/toposort.svg?branch=master&style=flat)](https://travis-ci.org/gustavohenke/toposort)\n[![Dependency Status](http://img.shields.io/gemnasium/gustavohenke/toposort.png?style=flat)](https://gemnasium.com/gustavohenke/toposort)\n\n__Sorting directed acyclic graphs, for Node.js, io.js and the browser__\n_This was originally done by Marcel Klehr. [Why not checkout his original repo?](https://github.com/marcelklehr/toposort)_\n\n## Installation\nThere are a few ways for installing Toposort. Here are them:\n\n* Via NPM: `npm install toposort-class`\n* Via Bower: `bower install toposort`\n* Via Git: `git clone git://github.com/gustavohenke/toposort.git`\n* [Direct download](https://raw.githubusercontent.com/gustavohenke/toposort/master/build/toposort.js) ([Minified](https://raw.githubusercontent.com/gustavohenke/toposort/master/build/toposort.min.js)) for use in the browser\n\n## Example\nLet's say you have the following dependency graph:\n\n* Plugin depends on Backbone and jQuery UI Button;\n* Backbone depends on jQuery and Underscore;\n* jQuery UI Button depends on jQuery UI Core and jQuery UI Widget;\n* jQuery UI Widget and jQuery UI Core depend on jQuery;\n* jQuery and Underscore don't depend on anyone.\n\nNow, how would you sort this in a way that each asset will be correctly placed? You'll probably need the following sorting:\n\n* `jQuery`, `jQuery UI Core`, `jQuery UI Widget`, `jQuery UI Button`, `Underscore`, `Backbone`, `Plugin`\n\nYou can achieve it with the following code, using `toposort-class`:\n```javascript\nvar Toposort = require('toposort-class'),\n\tt = new Toposort();\n\nt.add(\"jquery-ui-core\", \"jquery\")\n .add(\"jquery-ui-widget\", \"jquery\")\n .add(\"jquery-ui-button\", [\"jquery-ui-core\", \"jquery-ui-widget\"])\n .add(\"plugin\", [\"backbone\", \"jquery-ui-button\"])\n .add(\"backbone\", [\"underscore\", \"jquery\"]);\n\nconsole.log(t.sort().reverse());\n\n/* Will output:\n * ['jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-button', 'underscore', 'backbone', 'plugin']\n *\n * And you're done.\n */\n```\n\n## Usage\nCommonJS (Node.js and io.js):\n```javascript\nvar Toposort = require('toposort-class'),\n\tt = new Toposort();\n```\n\nBrowser with AMD:\n```javascript\ndefine(\"myModule\", [\"Toposort\"], function(Toposort) {\n    var t = new Toposort();\n});\n```\n\nBrowser without AMD:\n```javascript\nvar t = new window.Toposort();\n```\n\nor whatever global object there is instead of `window`.\n\n## API\n\n#### `.add(item, deps)`\n* _{String}_ `item` - The name of the dependent item that is being added\n* _{Array|String}_ `deps` - A dependency or list of dependencies of `item`\n\n__Returns:__ _{Toposort}_ The Toposort instance, for chaining.\n\n#### `.sort()`\n__Returns:__ _{Array}_ The list of dependencies topologically sorted.\n\nThis method will check for cyclic dependencies, like \"A is dependent of A\".\n\n#### `.clear()`\n__Returns:__ _{Toposort}_ The Toposort instance, for chaining.\n\nClears all edges, effectively resetting the instance.\n\n#### `.Toposort`\n\nReference to the Toposort constructor.\n\n## Legal\nMIT License\n","publish_time":1438304835342,"_cnpm_publish_time":1438304835342,"dist-tags":{"beta":"1.0.0","latest":"1.0.1"}}