New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@datastructures-js/priority-queue

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datastructures-js/priority-queue

A heap-based implementation of priority queue in javascript with typescript support.

  • 6.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-95.77%
Maintainers
1
Weekly downloads
 
Created

What is @datastructures-js/priority-queue?

@datastructures-js/priority-queue is an npm package that provides a robust implementation of a priority queue data structure. It allows you to manage a collection of elements where each element is associated with a priority, and elements are served based on their priority.

What are @datastructures-js/priority-queue's main functionalities?

Creating a Priority Queue

This code demonstrates how to create a new instance of a MinPriorityQueue using the @datastructures-js/priority-queue package.

const { MinPriorityQueue } = require('@datastructures-js/priority-queue');
const pq = new MinPriorityQueue();

Adding Elements

This code shows how to add elements to the priority queue with associated priorities.

pq.enqueue('task1', 1);
pq.enqueue('task2', 2);

Removing Elements

This code demonstrates how to remove and return the element with the highest priority from the priority queue.

const highestPriorityElement = pq.dequeue();

Peeking at the Highest Priority Element

This code shows how to peek at the element with the highest priority without removing it from the queue.

const highestPriorityElement = pq.front();

Checking if the Queue is Empty

This code demonstrates how to check if the priority queue is empty.

const isEmpty = pq.isEmpty();

Other packages similar to @datastructures-js/priority-queue

Keywords

FAQs

Package last updated on 06 Jan 2025

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