react-fifo

1.3.4 • Public • Published

What is this ?

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.

Installation

npm i react-fifo

Methods

Push

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)

Pop

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

Size

Use - To get the current size of the queue

        queue.size()

Empty

Use - To check if the queue is empty or not

        queue.isEmpty()

Front

Use - To get the front element of the queue

        queue.front()
This returns "empty" if queue is empty else returns the element

Example

Showing adding 4 elements, printing and removing all

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();
}

Package Sidebar

Install

npm i react-fifo

Weekly Downloads

1

Version

1.3.4

License

ISC

Unpacked Size

2.05 kB

Total Files

3

Last publish

Collaborators

  • talhashamim