Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

priorityqueuejs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

priorityqueuejs

a simple priority queue data structure

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
624K
increased by84.39%
Maintainers
1
Weekly downloads
 
Created

What is priorityqueuejs?

The priorityqueuejs npm package provides a simple and efficient implementation of a priority queue data structure in JavaScript. It allows you to manage a collection of elements where each element is associated with a priority, and elements are dequeued in order of their priority.

What are priorityqueuejs's main functionalities?

Basic Priority Queue Operations

This feature demonstrates the basic operations of a priority queue, including enqueuing elements with different priorities and dequeuing them in order of their priority.

const PriorityQueue = require('priorityqueuejs');

const pq = new PriorityQueue((a, b) => b - a);

pq.enq(5);
pq.enq(1);
pq.enq(3);

console.log(pq.deq()); // Outputs: 5
console.log(pq.deq()); // Outputs: 3
console.log(pq.deq()); // Outputs: 1

Peek at the Highest Priority Element

This feature allows you to peek at the highest priority element without removing it from the queue.

const PriorityQueue = require('priorityqueuejs');

const pq = new PriorityQueue((a, b) => b - a);

pq.enq(5);
pq.enq(1);
pq.enq(3);

console.log(pq.peek()); // Outputs: 5

Check if the Queue is Empty

This feature allows you to check if the priority queue is empty.

const PriorityQueue = require('priorityqueuejs');

const pq = new PriorityQueue((a, b) => b - a);

console.log(pq.isEmpty()); // Outputs: true

pq.enq(5);

console.log(pq.isEmpty()); // Outputs: false

Other packages similar to priorityqueuejs

Keywords

FAQs

Package last updated on 07 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc