This library has a Queue with the following methods: enqueue and dequeue. Enqueue adds item(s) to end of the Queue. Dequeue removes and returns the first item from the beginning of the queue.
Many algorithms use FIFO queues. Although javascript has build in methods for FIFO, the terms seem somewhat cryptic to me. Whenever I needed to add a queue, I found myself searching MDN for the correct array methods. As a result, I decided to write a very simple library / adapter to make working with queues a little easier. Now when I want to use a queue, I can simple install this package.
Import the package from npm
npm install queue-you-js
Import the package into your project.
var Queue = require("queue-you-js")
var queue = new Queue();
queue.enqueue("hi");
queue.getItems();
OR
import Queue from 'queue-you-js';
const queue = new Queue();
queue.enqueue("hi");
queue.getItems();
const queue = new Queue();
const queue = new Queue(["item", "item", "more items"]);
queue.dequeu();
queue.peek();
const firstItem = queue.dequeu();
queue.enqueue("item")
queue.enqueue(["item1", "item2"])
queue.getItems()
Also:
queue.items