Skip to content

rutvij26/treep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Treep

npm version License: MIT TypeScript

Treep is a lightweight, ultra-fast TypeScript library for graph and tree data structures with comprehensive traversal algorithms. It uses a clean tree metaphor throughout: Node → Leaf, Edge → Branch.

Features

  • 🌳 Tree Metaphor: Intuitive API using leaves and branches
  • Ultra-Fast: Optimized for large datasets (1M+ nodes)
  • 🔒 Type-Safe: Full TypeScript generics with type inference
  • 📦 Zero Dependencies: Pure TypeScript/JavaScript
  • 🎯 Framework-Agnostic: Works in Node.js, browser, React, Vue, Angular, React Native
  • 🚀 Comprehensive: BFS, DFS, shortest path, cycle detection, and more
  • Schema Validation: Built-in validation with tree path notation

Installation

npm install treep

Quick Start

import { Graph, BFS, shortestPath } from 'treep';

// Create a graph
const graph = new Graph<User>();

// Add leaves (nodes)
const alice = graph.addLeaf({ name: 'Alice', age: 30 }, 'alice');
const bob = graph.addLeaf({ name: 'Bob', age: 25 }, 'bob');
const charlie = graph.addLeaf({ name: 'Charlie', age: 35 }, 'charlie');

// Add branches (edges)
graph.addBranch(alice, bob);
graph.addBranch(bob, charlie);

// BFS traversal
const visited = BFS(alice, (leaf) => {
  console.log(leaf.value.name);
});

// Shortest path
const path = shortestPath(alice, charlie);

Requirements

  • Node.js: 20+ (LTS)
  • TypeScript: 5.0+
  • Browsers: Modern browsers only (Chrome, Edge, Firefox, Safari)

Documentation

📚 View Full Documentation - Comprehensive guide with examples, API reference, and interactive code snippets.

See examples for more usage examples.

Author

Rutvij Sathe

License

MIT © Rutvij Sathe

About

Treep is a lightweight, ultra-fast TypeScript library for graph and tree data structures with comprehensive traversal algorithms

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors