brainblocks.js
v1.0.22
Published
<h1 align="center">๐ง BrainBlocks</h1> <p align="center">A fun, beginner-friendly JavaScript DSA library โ build your brain, one block at a time!</p>
Readme
๐ Overview
BrainBlocks is a playful and educational JavaScript library for learning and using Data Structures and Algorithms (DSA).
It uses memorable names like:
- ๐
Backpackโ Stack - ๐
Lineโ Queue - ๐ ASCII CLI Utilities (intro, logo, quote, joke, etc.)
๐ฆ Installation
npm install brainblocks.js
| Function | Output |
| ------------ | ---------------------------------- |
| `intro()` | Prints welcome message |
| `logo()` | BrainBlocks ASCII banner logo |
| `say("msg")` | Prints ๐งฑ followed by your message |
| `quote()` | Random DSA quote in a box |
| `joke()` | Random developer joke |
| `motivate()` | Prints encouragement |
const brain = require('brainblocks.js');
brain.intro();
brain.logo();
brain.say("Let's master DSA!");
brain.quote();
| Method | Description |
| ------------ | ------------------------------ |
| `pack(item)` | Push item onto the stack |
| `unpack()` | Pop the top item |
| `peek()` | View top item without removing |
| `isEmpty()` | Check if the stack is empty |
| `size()` | Number of items in the stack |
*** how to use it ***
const brain = require('brainblocks.js');
const bag = new brain.Backpack(3);
bag.pack("๐ Book");
bag.pack("๐ Notes");
console.log(bag.peek()); // ๐ Notes
bag.unpack(); // Removes Notes
console.log(bag.peek()); // ๐ Book
***Queue***
| Method | Description |
| ------------ | -------------------------------- |
| `join(item)` | Add item to the end of queue |
| `leave()` | Remove item from the front |
| `peek()` | View first item without removing |
| `isEmpty()` | Check if queue is empty |
| `size()` | Number of items in the queue |
const line = new brain.Line(2);
line.join("Alice");
line.join("Bob");
console.log(line.peek()); // Alice
line.leave();
console.log(line.peek()); // Bob