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

tinyqueue

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinyqueue

The smallest and simplest JavaScript priority queue

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
increased by4.79%
Maintainers
1
Weekly downloads
 
Created

What is tinyqueue?

The tinyqueue npm package is a minimal priority queue implementation in JavaScript. It is designed to be very lightweight and fast, and it is often used for tasks that require a priority queue, such as pathfinding algorithms, scheduling, and event handling.

What are tinyqueue's main functionalities?

Creating a priority queue

This code sample demonstrates how to import the TinyQueue class and create a new priority queue instance.

const TinyQueue = require('tinyqueue');
const queue = new TinyQueue();

Adding items to the queue

This code sample shows how to add items to the queue with a specified priority. The lower the priority number, the sooner the item will be dequeued.

queue.push({ value: 'item1', priority: 1 });
queue.push({ value: 'item2', priority: 2 });

Removing the item with the highest priority

This code sample demonstrates how to remove and return the item with the highest priority (the item with the lowest priority number) from the queue.

const highestPriorityItem = queue.pop();

Peeking at the item with the highest priority without removing it

This code sample shows how to look at the item with the highest priority without removing it from the queue.

const highestPriorityItem = queue.peek();

Checking the size of the queue

This code sample demonstrates how to check the number of items in the queue.

const size = queue.length;

Other packages similar to tinyqueue

Keywords

FAQs

Package last updated on 06 Jul 2024

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