Queue data structure as npm package
This package helps you to simulate the behaviour of a queue.
If you are familiar with c++ queues this has exactly same methods.
npm i react-fifo
Use - For inserting/pushing data to queue if you want to push say 1,2,3
queue.push(1)
queue.push(2)
queue.push(3)
Use - For removing data from queue
queue.pop()
This is follow the property of queue and pop the front element
If there are no element it returns -1 and if popped will return 1
Use - To get the current size of the queue
queue.size()
Use - To check if the queue is empty or not
queue.isEmpty()
Use - To get the front element of the queue
queue.front()
This returns "empty" if queue is empty else returns the element
const queue = require('react-fifo');
queue.push(1);
queue.push(2);
queue.push(3);
queue.push(4);
while(!queue.isEmpty()){
console.log(queue.front());
queue.pop();
}