A TypeScript monorepo for data structures and algorithms, inspired by Java's Collections Framework. Managed with pnpm workspaces, typed with TypeScript, and tested with Vitest.
This monorepo contains the following packages:
-
@ds-algo/collectionsβ Collection framework- Core interfaces:
Collection,Iterable,Iterator,List(done) - Abstract base classes:
AbstractCollection,AbstractList(done) - Concrete implementations:
ArrayList(done), more planned - Utilities:
Collectionsaggregator (done)
- Core interfaces:
-
@ds-algo/algorithmsβ Algorithms library- Package scaffold, build config, and tests setup present
- Algorithm modules planned; exports not finalized yet
packages/
βββ collections/ # Collection framework
β βββ src/
β β βββ interfaces/ # Core interfaces (Collection, Iterable, Iterator, List)
β β βββ abstracts/ # Abstract base classes (AbstractCollection, AbstractList)
β β βββ classes/ # Concrete implementations (ArrayList, Collections)
β β βββ index.ts # Main exports
β βββ tests/ # Unit tests (e.g., ArrayList.test.ts)
β βββ README.md # Package documentation
βββ algorithms/ # Algorithm implementations (scaffolded)
βββ src/
β βββ index.ts # Main exports (TBD)
βββ tests/ # Test files
βββ README.md # Package documentation
- Node.js 18+
- pnpm 8+
# Clone the repository
git clone https://github.com/msboffl/ds-algo.git
cd ds-algo
# Install workspace dependencies
pnpm install
# (Optional) Generate a fresh project tree snapshot
pnpm run generate:tree# Build all workspaces (recursive)
pnpm -r run build
# Build a specific package
pnpm --filter @ds-algo/collections run build
pnpm --filter @ds-algo/algorithms run build# Run all package tests (recursive)
pnpm -r run test
# Run tests in a specific package
pnpm --filter @ds-algo/collections run test
pnpm --filter @ds-algo/algorithms run testimport { ArrayList, List } from '@ds-algo/collections';
const list: List<number> = new ArrayList<number>();
list.add(1);
list.add(2);Exports are being stabilized. Examples will be added as implementations land.
# Format repository
pnpm run prettier:format
# Check formatting
pnpm run prettier:check
# Package dev mode (example)
pnpm --filter @ds-algo/collections run dev
# Clean build artifacts (package level)
pnpm --filter @ds-algo/collections run clean-
Collections
- Add/extend interfaces in
packages/collections/src/interfaces/ - Implement shared logic in
packages/collections/src/abstracts/ - Implement concrete classes in
packages/collections/src/classes/ - Add tests under
packages/collections/src/tests/ - Export from
packages/collections/src/index.ts
- Add/extend interfaces in
-
Algorithms
- Implement algorithms under category folders (to be introduced)
- Export from
packages/algorithms/src/index.ts - Add tests under
packages/algorithms/tests/ - Document usage in
packages/algorithms/README.md
Each package includes or plans to include:
- Unit tests with various input sizes
- Edge case testing
- Performance checks where appropriate
- Type safety verification
- β Core interfaces implemented (Collection, Iterable, Iterator, List)
- β Abstract base classes implemented (AbstractCollection, AbstractList)
- β
ArrayListimplemented;Collectionsutilities available - π Additional concrete structures (LinkedList, Set, Map) planned
- π Collection-specific algorithms planned
- β Package structure and build configuration
- π Algorithm implementations under development
- π Exports and API surface to be finalized
- Type-safe interfaces with full TypeScript support
- Generic collections for any data type
- Iterator pattern for consistent iteration
- Extensible design for custom implementations
- Java-inspired architecture for familiarity
- Well-tested implementations with comprehensive test coverage
- Performance optimized with complexity analysis
- Multiple algorithm categories (sorting, searching, graph, etc.)
- TypeScript-first with proper type definitions
- Educational focus with clear documentation
- Collections Package β Collection framework
- Algorithms Package β Algorithms library
- API reference and benchmarks are planned under
docs/.
We welcome contributions! Please see our Contributing Guide if available.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with appropriate tests
- Ensure all tests pass (
pnpm -r run test) - Submit a pull request
- Follow TypeScript best practices
- Write comprehensive tests for new features
- Include JSDoc comments for public APIs
- Update relevant documentation
- Ensure code formatting with Prettier
This project is licensed under the MIT License β see the LICENSE file for details.
- Inspired by Java's Collections Framework
- Built with modern TypeScript practices
- Testing with Vitest
- Monorepo management with pnpm workspaces
- Add LinkedList, Stack, Queue to collections
- Establish algorithms module layout and initial exports
- Basic sorting/searching algorithms
- Expand unit tests
- Graph and dynamic programming algorithms
- String and mathematical algorithms
- Performance benchmarks
- Advanced data structures (trees, heaps, tries)
- Parallel/optimized variants
- Documentation site and interactive examples
- TypeScript Collections β
https://github.com/basarat/typescript-collections - javascript-algorithms β
https://github.com/trekhleb/javascript-algorithms - dsa.js β
https://github.com/amejiarosario/dsa.js
Note: This is an active development project. Check the Issues page for current development status and planned features.