Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alisawari/ts-data-structure
Implemented most useful and important Data Structures used in Software Development, All With TypeScript 🌟
https://github.com/alisawari/ts-data-structure
data-structures datastructures typescript
Last synced: about 24 hours ago
JSON representation
Implemented most useful and important Data Structures used in Software Development, All With TypeScript 🌟
- Host: GitHub
- URL: https://github.com/alisawari/ts-data-structure
- Owner: AliSawari
- License: mit
- Created: 2022-02-05T09:00:02.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-16T16:32:26.000Z (2 months ago)
- Last Synced: 2024-11-16T17:26:28.470Z (2 months ago)
- Topics: data-structures, datastructures, typescript
- Language: TypeScript
- Homepage: https://alisawari.github.io/ts-data-structure/
- Size: 170 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Data Structure and Algorithms - TypeScript [![Build & Test](https://github.com/AliSawari/js-data-structure/actions/workflows/node.js.yml/badge.svg)](https://github.com/AliSawari/js-data-structure/actions/workflows/node.js.yml)
**Implemented most useful and important Data Structures used in Software Development, All With TypeScript 🌟**
## Table of Contents
- [Introduction](#data-structure-with-typeScript)
- [Examples](#examples)## List of Implemented Data Structures
- [x] Linked Lists
1. Simple Linked List
2. Doubly Linked Lists
- [x] Stacks
- [x] Queues
- [ ] Trees## Data Structure with TypeScript
the benefits of using the Type system from TypeScript is the ability to create new types alongside the class
definitions, which allows you to implement the Data Structure types easily and correctly.I've tried to be as close as possible to the real use cases of Data Structures in Real life and
in the classic definitions.## Examples
here's a quick type definition of Linked List.
```ts
type LinkedListType = {
length: number;
head: NodeType | null;
tail: NodeType | null;
push?(value: any): LinkedListType;
pop?(): NodeType | unknown;
shift?(): NodeType | unknown;
unshift?(value: any): LinkedListType;
get?(index: number): NodeType | unknown;
set?(index: number, value: any): boolean;
insert?(index: number, value: any): void;
remove?(value: any): NodeType | unknown;
reverse?(): void;
log?(): void;
};
```you can see that each property or method has a declared type. the `value` of a linked list however can be different, thats why `any` would make sense. A Generic type will be implemented soon.
### Run
You can run the example and testing files with this command:
```bash
npm run examples
```To compile the project, simply run:
```bash
npm run build
```### Testing
Run tests with `npm test`.
Each Test file is related to one data structure(each file for subgroups)
the goal of the unit testing files is to assert the correctness of the implemented Data Structure. you can find tests in the [tests](./tests/) Directory.### License
This repo is under MIT License
Happy Hacking 🥷