topological-sort
Advanced tools
Comparing version 0.1.5 to 0.2.0
{ | ||
"name": "topological-sort", | ||
"version": "0.1.5", | ||
"description": "Topological sort implemented in Javascript", | ||
"main": "build.js", | ||
"version": "0.2.0", | ||
"description": "Topological sort", | ||
"main": "dist/index.js", | ||
"repository": { | ||
@@ -11,21 +11,30 @@ "type": "git", | ||
"scripts": { | ||
"prepublish": "./node_modules/.bin/babel index.js --out-file build.js", | ||
"test": "mocha test/" | ||
"build": "tsc", | ||
"clean": "rm -fr dist/", | ||
"lint": "tslint -p . -c tslint.json 'src/*.ts'", | ||
"prepublishOnly": "npm run clean && npm run build", | ||
"test:unit": "mocha --require ts-node/register src/*.spec.ts", | ||
"test": "npm run lint && npm run test:unit" | ||
}, | ||
"author": "Dmitry Sorin <info@staypositive.ru>", | ||
"author": "Dmitrii Sorin <info@staypositive.ru>", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=8" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.10.1", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-array-includes": "^2.0.3", | ||
"babel-plugin-transform-es2015-destructuring": "^6.9.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.10.3", | ||
"babel-plugin-transform-es2015-parameters": "^6.11.3", | ||
"babel-plugin-transform-es2015-spread": "^6.8.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.8.0", | ||
"mocha": "^2.5.3" | ||
} | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.5.2", | ||
"mocha": "^5.0.0", | ||
"ts-node": "^7.0.0", | ||
"tslint": "^5.11.0", | ||
"typescript": "^2.9.2" | ||
}, | ||
"keywords": [ | ||
"topological sort", | ||
"topological", | ||
"sort", | ||
"graph", | ||
"dependencies" | ||
], | ||
"types": "dist/index.d.ts" | ||
} |
@@ -1,8 +0,14 @@ | ||
# Topological sort implemented in Javascript (ES2016) | ||
# Topological sort | ||
[](https://greenkeeper.io/) | ||
[](https://travis-ci.org/1999/topological-sort) | ||
[](https://david-dm.org/1999/topological-sort#info=devDependencies) | ||
This package is distributed as Javascript, but you can also use it in your TypeScript project. | ||
## API | ||
### Javascript example | ||
```javascript | ||
const TopologicalSort = require('topological-sort'); | ||
const { TopologicalSort } = require('topological-sort'); | ||
@@ -35,2 +41,21 @@ // you can pass nodes as a map into constructor: | ||
### Typescript example | ||
```typescript | ||
import TopologicalSort from 'topological-sort'; | ||
// TopologicalSort class instances have a map inside. | ||
// This map stores the references between your nodes (edges) | ||
// "NodesKeyType" is the type for your tree node identifiers | ||
// "NodesValueType" is the type for your tree nodes | ||
const nodes = new Map<NodesKeyType, NodesValueType>(); | ||
nodes.set('variables', variablesObj); | ||
nodes.set('mixins', mixinsObj); | ||
const sortOp = new TopologicalSort<NodesKeyType, NodesValueType>(nodes); | ||
sortOp.addEdge('variables', 'mixins'); | ||
const sorted = sortOp.sort(); | ||
const sortedKeys = [...res.keys()]; // ['variables', 'mixins'] | ||
``` | ||
## More info: | ||
@@ -37,0 +62,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43840
6
16
671
66
1