JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21841
  • Score
    100M100P100Q151347F
  • License MIT

queue implementation in javascript

Package Exports

  • @datastructures-js/queue

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@datastructures-js/queue) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Queue

build:? npm npm npm

elements data type: any type.

Usage

const queueFn = require('@datastructures-js/queue');
const queue = queueFn();

API

.enqueue(element)

adds an element to the back of the queue.

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

.front()

returns the front element in queue.

console.log(queue.front()); // 10

.back()

returns the back element in the queue.

console.log(queue.back()); // 20

.dequeue()

dequeues an element from the queue.

console.log(queue.dequeue()); // 10
console.log(queue.front()); // 20

.isEmpty()

checks if the queue is empty.

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

.length()

returns the length of the queue

console.log(queue.length()); // 1

.toArray()

converts the queue to an array with front starting at 0

queue.enqueue(1);
queue.enqueue(4);
queue.enqueue(2);
console.log(queue.toArray()); // [1, 4, 2]

.clear()

clears the queue

queue.clear();
queue.length(); // 0

Build

grunt build

License

The MIT License. Full License is here