1.0.1 • Published 10 months ago

namastey-queue v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

namastey-queue

Brief Description

namastey-queue is a JavaScript package that provides an implementation of a Queue data structure with various important methods. A Queue follows the First In, First Out (FIFO) principle.

Features

  • enqueue(item): Adds an item to the end of the queue.
  • dequeue(): Removes and returns the item from the front of the queue. Returns a message if the queue is empty.
  • peek(): Returns the item at the front of the queue without removing it. Returns a message if the queue is empty.
  • isEmpty(): Checks if the queue is empty. Returns true if empty, otherwise false.
  • size(): Returns the number of items in the queue.
  • printQueue(): Prints all items in the queue as a comma-separated string.

Installation

To install the package globally, run:

npm install -g namastey-queue

Examples

const Queue = require('namastey-queue');

const queue = new Queue();

queue.enqueue(10);
queue.enqueue(20);
queue.enqueue(30);

console.log(queue.peek()); // Output: 10
console.log(queue.size()); // Output: 3

queue.printQueue(); // Output: 10,20,30

console.log(queue.dequeue()); // Output: 10
queue.printQueue(); // Output: 20,30

console.log(queue.isEmpty()); // Output: false