{"id":25490186,"url":"https://github.com/fix2015/structure_queue","last_synced_at":"2025-07-12T20:12:15.517Z","repository":{"id":273065180,"uuid":"918602366","full_name":"fix2015/structure_queue","owner":"fix2015","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-18T12:04:19.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-18T23:34:59.365Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fix2015.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-18T11:18:30.000Z","updated_at":"2025-01-18T14:41:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"eeb00833-f9a9-4d56-bc8c-c510c66ec2ba","html_url":"https://github.com/fix2015/structure_queue","commit_stats":null,"previous_names":["fix2015/structure_queue"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fix2015/structure_queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fix2015","download_url":"https://codeload.github.com/fix2015/structure_queue/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_queue/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265047848,"owners_count":23703218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-18T21:27:28.203Z","updated_at":"2025-07-12T20:12:15.505Z","avatar_url":"https://github.com/fix2015.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Queue Data Structure in JavaScript 🚀  \nTiktok tu\n\nA simple implementation of the **Queue** data structure in JavaScript. This repository demonstrates how to create a queue class with essential methods and explains its functionality with practical examples.  \n\n---\n\n## What is a Queue?  \nA **Queue** is a data structure that follows the **FIFO** (First In, First Out) principle. The first element added to the queue is the first one to be removed. Think of it as a line at a coffee shop: the first person in line gets served first.  \n\n---\n\n## Features  \n- **Enqueue**: Add an item to the queue.  \n- **Dequeue**: Remove and return the first item.  \n- **Peek**: View the first item without removing it.  \n- **isEmpty**: Check if the queue is empty.  \n- **Size**: Get the number of items in the queue.  \n\n---\n\n## TikTok Tutorial 🎥  \nWant to see a quick tutorial on how to build this? Check out this TikTok video:  \n[https://www.tiktok.com/@jsmentoring/video/7461216459239247136](https://www.tiktok.com/@jsmentoring/video/7461216459239247136)  \n\n---\n\n## Code Implementation  \n\nHere’s the JavaScript implementation of the queue:  \n\n```javascript\nclass Queue {\n    constructor() {\n        this.items = []; // Initialize an empty array\n    }\n\n    // Add an item to the queue\n    enqueue(element) {\n        this.items.push(element);\n    }\n\n    // Remove and return the front item\n    dequeue() {\n        if (this.isEmpty()) {\n            return \"Queue is empty!\";\n        }\n        return this.items.shift();\n    }\n\n    // Check if the queue is empty\n    isEmpty() {\n        return this.items.length === 0;\n    }\n\n    // Peek at the front item without removing it\n    peek() {\n        if (this.isEmpty()) {\n            return \"Queue is empty!\";\n        }\n        return this.items[0];\n    }\n\n    // Get the size of the queue\n    size() {\n        return this.items.length;\n    }\n}\n```\n\n---\n\n## Example Usage  \n\n```javascript\n// Initialize the queue\nconst queue = new Queue();\n\n// Add items to the queue\nqueue.enqueue(\"Task 1\");\nqueue.enqueue(\"Task 2\");\nqueue.enqueue(\"Task 3\");\n\n// Peek at the front item\nconsole.log(queue.peek()); // Output: Task 1\n\n// Remove items from the queue\nconsole.log(queue.dequeue()); // Output: Task 1\nconsole.log(queue.dequeue()); // Output: Task 2\n\n// Check if the queue is empty\nconsole.log(queue.isEmpty()); // Output: false\n\n// Get the size of the queue\nconsole.log(queue.size()); // Output: 1\n```\n\n---\n\n## Real-World Applications  \n1. **Task Scheduling**: Managing tasks in order of arrival.  \n2. **Print Queue**: Handling print jobs in a printer.  \n3. **Breadth-First Search (BFS)**: Traversing graphs or trees.  \n4. **Customer Service Systems**: Serving customers in the order they arrive.  \n\n---\n\n## How to Run the Code  \n1. Clone the repository:  \n   ```bash\n   git clone https://github.com/your-username/queue-data-structure.git\n   cd queue-data-structure\n   ```\n2. Open the file `queue.js` in your favorite code editor.  \n3. Run the file using Node.js:  \n   ```bash\n   node queue.js\n   ```\n\n---\n\n## Contributing  \nContributions are welcome! If you have suggestions or want to add new features, feel free to create a pull request.  \n\n---\n\n## License  \nThis project is licensed under the MIT License.  \n\n---\n\n## Connect with Me:\n- [LinkedIn - Vitalii Semianchuk](https://www.linkedin.com/in/vitalii-semianchuk-9812a786/)\n- [Telegram - @jsmentorfree](https://t.me/jsmentorfree) - We do a lot of free teaching on this channel! Join us to learn and grow in web development.\n- [Tiktok - @jsmentoring](https://www.tiktok.com/@jsmentoring) Everyday new videos\n- [Youtube - @jsmentor-uk](https://www.youtube.com/@jsmentor-uk) Mentor live streams\n- [Dev.to - fix2015](https://dev.to/fix2015) Javascript featured, live, experience\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffix2015%2Fstructure_queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffix2015%2Fstructure_queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffix2015%2Fstructure_queue/lists"}