1.0.0 • Published 4 years ago

toposort-ts v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Universal Topological Sort

Supports both JavaScript/TypeScript and HTML imports

npm.io

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[];

Reference

1.0.1

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago