1.0.0 • Published 4 years ago
toposort-ts v1.0.0
Universal Topological Sort
Supports both JavaScript/TypeScript and HTML imports
JavaScript/TypeScript import example
installation
npm install toposort-ts
Using import
import toposort from 'toposort-ts';
const edges: [number, number][] = [
[1, 2],
[2, 3],
];
console.log(toposort(edges));
// [1, 2, 3]
Using require
const toposort = require('toposort-ts');
const edges: [number, number][] = [
[1, 2],
[2, 3],
];
console.log(toposort(edges));
// [1, 2, 3]
HTML import example
<html lang="en">
<head>
<script src="https://cdn.jsdelivr.net/npm/toposort-ts/build/toposort.min.js"></script>
</head>
<body>
<script>
console.log(
toposort([
[1, 2],
[2, 3],
]),
);
</script>
</body>
</html>
API
this module only export toposort
function (and as default). Here is its
function signature:
function toposort<N extends string | number>(edges: [N, N][]): N[];