js-dsa-utils
Version:
Basic DSA utilities (sorting, searching, stack, queue,linked list etc.)
68 lines (53 loc) • 1.44 kB
Markdown
# 📦 js-dsa-utils
**A beginner-friendly JavaScript utility package for common Data Structures and Algorithms**, created by [Suman Dey](https://github.com/sumandey2023).
Use this package to practice and build with DSA concepts like **sorting, searching, stack, queue, and linked list** — all in one lightweight NPM module.
---
## 🚀 Features
- 🔢 Bubble, Selection, Insertion, Merge Sort
- 🔍 Binary Search
- 🧮 Factorial & Fibonacci
- 📦 Stack (class-based)
- 📥 Queue (class-based)
- 🔗 Singly Linked List (insert, delete, search)
---
## 📦 Installation
```bash
npm install js-dsa-utils
```
```js
const {
bubbleSort,
selectionSort,
insertionSort,
mergeSort,
binarySearch,
factorial,
fibonacci,
Stack,
Queue,
SinglyLinkedList,
} = require("js-dsa-utils");
// Sorting
console.log(bubbleSort([5, 3, 1])); // [1, 3, 5]
// Searching
console.log(binarySearch([1, 3, 5], 3)); // 1
// Math
console.log(factorial(5)); // 120
console.log(fibonacci(6)); // 8
// Stack
const stack = new Stack();
stack.push(10);
stack.push(20);
console.log(stack.pop()); // 20
// Queue
const queue = new Queue();
queue.enqueue(1);
queue.enqueue(2);
console.log(queue.dequeue()); // 1
// Singly Linked List
const list = new SinglyLinkedList();
list.insertAtHead(10);
list.insertAtTail(20);
list.delete(10);
console.log(list.toArray()); // [20]
```