# flatqueue **Repository Path**: mirrors_mourner/flatqueue ## Basic Information - **Project Name**: flatqueue - **Description**: A very fast and simple JavaScript priority queue - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2026-03-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # flatqueue A very fast and tiny binary heap priority queue in JavaScript. Similar to [tinyqueue](https://github.com/mourner/tinyqueue/), but stores the queue as two flat arrays of items and their numeric priority values respectively (without a way to specify a comparator function). This makes the queue more limited, but several times faster. [![Build Status](https://github.com/mourner/flatqueue/actions/workflows/node.yml/badge.svg)](https://github.com/mourner/flatqueue/actions/workflows/node.yml) [![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects) ## Usage ```js const q = new FlatQueue(); for (let i = 0; i < items.length; i++) { // Push an item index and its priority value. You can push other values as well, // but storing only integers is much faster due to JavaScript engine optimizations. q.push(i, items[i].priority); } q.peekValue(); // Read the top item's priority value q.peek(); // Read the top item q.pop(); // Remove and return the top item ``` ## Install Install with `npm install flatqueue`, then use as a module: ```js import FlatQueue from 'flatqueue'; ``` Alternatively, use as a module in a browser directly: ```html