pertain
Version:
Automated pub/sub across project dependencies. Run code from any installed package based on declarative rules in package.json
17 lines (16 loc) • 573 B
TypeScript
/**
* Topologically sort a list of items of any type, given a list of items and
* a map of outward relations between those items. (Could be a function, but
* it's a class for testability.)
*
* Credit to https://github.com/marcelklehr/toposort/ for a great
* implementation I had to adapt to be faster for our particular use case.
*
* That code appears here courtesy of the MIT license.
*/
export default class TopologicalSorter<T> {
private outgoingFrom;
constructor(outgoingFrom: (node: T) => T[]);
sort(nodes: T[]): T[];
private makeNodesHash;
}