fueue

    1.0.0 • Public • Published

    fueue

    Fast performance queue implementation in ES6

    This module is the implementer of the basic queue and it's much faster and more intuitive than Naive queue implementations.

    Install

    npm install fueue

    API

    Create an instance

    const Queue = require('fueue');
     
    const q = new Queue();

    Methods

    push(value)

    Insert value into the queue.

    q.push(10);
    q.push('blah');

    pop()

    Remove the next elements from the queue and return it.

    q.push(10);
    q.push('blah');
     
    let f = q.pop();
    console.log(f);
    // output: 10
     
    = q.pop();
    console.log(f);
    // output: "blah"

    front()

    Returns the next element in the queue.

    q.push('blah');
     
    let f = q.front();
    console.log(f);
    // output: "blah"

    back()

    Returns the last element in the queue.

    q.push('blah');
    q.push(1996);
     
    let b = q.back();
    console.log(b);
    // output: 1996

    empty()

    Returns whether the queue is empty.

    let isEmpty = q.empty();
    console.log(isEmpty);
    // output: true
     
    q.push(1);
    isEmpty = q.empty();
    console.log(isEmpty);
    // output: false

    size()

    Returns the number of elements remaining in the queue.

     
    let size = q.size();
    console.log(size);
    // output: 0
     
    for(let i = 0; i < 10; ++i) {
        q.push(i);
    }
     
    size = q.size();
    console.log(size);
    // output: 10

    Install

    npm i fueue

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    3.36 kB

    Total Files

    3

    Last publish

    Collaborators

    • blurfx