{"id":45956,"library":"qheap","title":"qheap - Binary Heap Priority Queue","description":"qheap is a fast binary heap / priority queue library for Node.js (v1.4.0, stable, low release cadence). It supports insert, remove, peek, and heap operations with O(log n) complexity. Compared to alternatives like fastpriorityqueue, qheap offers good performance and a simple API. Primary use cases include scheduling, event loops, and Graph algorithms. The package is pure JavaScript without native bindings, making it portable across platforms.","status":"active","version":"1.4.0","language":"javascript","source_language":"en","source_url":"git://github.com/andrasq/node-qheap","tags":["javascript","Andras","binary","heap","priority queue"],"install":[{"cmd":"npm install qheap","lang":"bash","label":"npm"},{"cmd":"yarn add qheap","lang":"bash","label":"yarn"},{"cmd":"pnpm add qheap","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS only; ESM import will fail.","wrong":"import Heap from 'qheap';","symbol":"Heap","correct":"const Heap = require('qheap');"},{"note":"The module exports the constructor directly; no named export.","wrong":"const h = new Qheap({ compar: myCompar });","symbol":"Heap constructor (options)","correct":"const h = new Heap({ compar: myCompar });"},{"note":"If options is a function, it is taken as the comparator function (like compar option).","wrong":"const h = new Heap({ compar: myCompar });","symbol":"Heap with comparator function","correct":"const h = new Heap(myCompar);"}],"quickstart":{"code":"const Heap = require('qheap');\nconst h = new Heap();\nh.insert('c');\nh.insert('a');\nh.insert('b');\nconsole.log(h.remove()); // 'a'\nconsole.log(h.peek()); // 'b'\nconsole.log(h.length); // 2","lang":"javascript","description":"Create a heap, insert items, remove the smallest, peek at the next, and check length."},"warnings":[{"fix":"Read length only; do not assign.","message":"length property is read-only; setting it will cause undefined behavior.","severity":"gotcha","affected_versions":"*"},{"fix":"Use compar or comparBefore option: new Heap({ comparBefore: (a,b) => a > b })","message":"Default comparison uses < (less than). For numbers works as min-heap. To get a max-heap, provide a custom comparBefore or compar function.","severity":"gotcha","affected_versions":"*"},{"fix":"Use gc() manually or enable freeSpace option on construction.","message":"gc() is available but not automatically called; memory may grow unbounded if freeSpace option is not set.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'across':69 'algorithm':57 'altern':37 'andra':72 'api':47 'binari':2,10,73 'bind':65 'cadenc':21 'case':50 'compar':35 'complex':34 'event':53 'fast':9 'fastpriorityqueu':39 'good':42 'graph':56 'heap':3,11,28,74 'includ':51 'insert':24 'javascript':62,71 'librari':14 'like':38 'log':32 'loop':54 'low':19 'make':66 'n':33 'nativ':64 'node.js':16 'o':31 'offer':41 'oper':29 'packag':59 'peek':26 'perform':43 'platform':70 'portabl':68 'primari':48 'prioriti':4,12,75 'pure':61 'qheap':1,6,40 'queue':5,13,76 'releas':20 'remov':25 'schedul':52 'simpl':46 'stabl':18 'support':23 'use':49 'v1.4.0':17 'without':63","created_at":"2026-06-07T12:57:33.287231+00:00","updated_at":"2026-06-07T12:57:33.287231+00:00","problems":[{"fix":"Use require('qheap') in CommonJS.","cause":"Using wrong import pattern (e.g., import Heap from 'qheap' in ESM).","error":"TypeError: heap.remove is not a function"},{"fix":"Use const Heap = require('qheap'); const h = new Heap();","cause":"Instantiating the heap incorrectly (e.g., new qheap() instead of new Heap()).","error":"TypeError: heap.insert is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/andrasq/node-qheap#readme","github":"git://github.com/andrasq/node-qheap","docs":null,"changelog":null,"pypi":null,"npm":"qheap","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}