TsAlgo
Typed data structures, algorithms, and utility functions library for JavaScript/TypeScript
Explore the docs »
NPM »
Report Bug
·
Request Feature
Installation
- Install with npm
npm install tsalgo
- or yarn
yarn add tsalgo
Usage
import { LinkedList } from 'tsalgo';
or import all
import * as Collections from 'tsalgo';
All implementations use TypeScript generics.
Use with TypeScript instead of JavaScript to get complete Intellisense + type-safety.
import { LinkedList } from 'tsalgo';
const ll = new LinkedList<number>();
ll.push(100); // push adds to the end of the list
ll.push(200);
ll.push(300);
// Current state = 100 -> 200 -> 300
console.log(ll.shift()); // prints 100
console.log(ll.pop()); // prints 300
console.log(ll.size); // prints 1
console.log(ll.pop()); // prints 200
console.log(ll.size); // prints 0
Roadmap
Currently supported data structures:
- LinkedList
- DoublyLinkedList (default)
- SinglyLinkedList
- Stack
- Queue
- Heap
- MinHeap (default)
- MaxHeap
- Priority Queue (Heap based)
This is a fairly new library, but I'm adding stuff everyday. See the open issues for a list of proposed features (and known issues).
Contributing
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/something
) - Commit your changes with commitizen (to follow semantic versioning) (
yarn commit
ornpm run commit
) - Push to the Branch (
git push origin feature/something
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.