UNPKG

topological-sort-group

Version:

Topological sorting and cycle detection. Optional grouping for parallel processing

28 lines (27 loc) 648 B
export interface GraphOptions { path?: string; } export type Key = string | number | symbol; export interface DependencyGraph<T> { nodes: Record<string, T>; dependencies: Record<string, string[]>; } export type Node<T = Key> = { value: T; edges: Key[]; }; export type Cycle = Key[]; export interface DuplicateKey<T = Key> { key: Key; values: T[]; } export interface SortResult<T = Key> { nodes: Node<T>[][]; cycles: Cycle[]; duplicates: DuplicateKey<T>[]; } export declare const SortMode: { readonly Group: 1; readonly Flat: 2; }; export type SortModeEnum = (typeof SortMode)[keyof typeof SortMode];