athro
v2.1.0
Published
A datastructures and algorithms library for TS/JS
Maintainers
Readme
Athro
Algorithms and data structures for TypeScript and JavaScript, with interactive documentation for every algorithm.
Documentation · Getting Started · npm · Issues
Overview
Athro is a typed library of classic algorithms and data structures. It ships dual CommonJS and ESM builds with TypeScript declarations, and works in Node.js, Bun, Deno, and modern browsers.
Each algorithm in the documentation includes an interactive step-by-step visualization.
Install
npm install athropnpm add athroyarn add athroQuick example
import { heapSort, Graph, graphBfs, dijkstra, HashMap, BinarySearchTree, bubbleSort } from 'athro';
// Sorting
bubbleSort([8, 3, 6, 2]);
heapSort([8, 3, 6, 1]);
// Hash map
const map = new HashMap<string, number>();
map.set('key', 42);
map.get('key'); // 42
// Graph
const graph = new Graph<string>(true);
graph.addEdge('A', 'B', 4);
graph.addEdge('B', 'C', 2);
graphBfs(graph, 'A');
dijkstra(graph, 'A', 'C');
// Binary search tree
const bst = new BinarySearchTree<number>();
bst.insert(10);
bst.isPresent(10); // trueUsage
Import named exports from the package entry point:
import { mergeSort, Stack, Queue } from 'athro';
const stack = new Stack<number>();
stack.push(1);
stack.push(2);
stack.pop();
mergeSort([4, 2, 7, 1, 3]);Browse the full API with examples and visualizations in the documentation.
Compatibility
| Environment | Supported | | -------------- | --------- | | Node.js | Yes | | Bun | Yes | | Deno | Yes | | Browsers (ESM) | Yes |
Requires a JavaScript runtime with ES2017 support.
