{"id":47194,"library":"bucket-priority-queue","title":"Bucket Priority Queue","description":"A TypeScript implementation of the bucket queue data structure, optimized for priority-based item management when the priority key space consists of small positive integers. Version 2.1.0 is the latest stable release, actively maintained. It offers extremely fast enqueue and dequeue operations, outperforming heap-based priority queues in benchmarks, making it ideal for algorithms like Dijkstra's. Ships with full TypeScript type definitions and supports both min and max bucket queues.","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/keriati/bucket-priority-queue","tags":["javascript","bucket","queue","priority","priority-queue","data-structure","data-structures","typescript"],"install":[{"cmd":"npm install bucket-priority-queue","lang":"bash","label":"npm"},{"cmd":"yarn add bucket-priority-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add bucket-priority-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export; default import will cause runtime error.","wrong":"import MinBucketQueue from 'bucket-priority-queue'","symbol":"MinBucketQueue","correct":"import { MinBucketQueue } from 'bucket-priority-queue'"},{"note":"Works with both ESM and CJS, but named export syntax is preferred.","wrong":"const { MaxBucketQueue } = require('bucket-priority-queue')","symbol":"MaxBucketQueue","correct":"import { MaxBucketQueue } from 'bucket-priority-queue'"},{"note":"Type export for the priority type (number).","wrong":"","symbol":"Priority","correct":"import type { Priority } from 'bucket-priority-queue'"}],"quickstart":{"code":"import { MinBucketQueue, MaxBucketQueue } from 'bucket-priority-queue';\n\n// Create a min bucket queue with initial items\nconst minQueue = new MinBucketQueue<number>([\n  [10, 2],\n  [20, 1],\n  [30, 3],\n]);\nconsole.log(minQueue.pop()); // 20 (lowest priority)\n\n// Create a max bucket queue\nconst maxQueue = new MaxBucketQueue<string>([\n  ['a', 1],\n  ['b', 3],\n  ['c', 2],\n]);\nconsole.log(maxQueue.pop()); // 'b' (highest priority)\n\n// Add items\nmaxQueue.push('d', 5);\nconsole.log(maxQueue.peek()); // 'd'\n\n// Check size\nconsole.log(maxQueue.size); // 3\n\n// Clear\nmaxQueue.clear();\nconsole.log(maxQueue.isEmpty()); // true","lang":"typescript","description":"Shows instantiation with initial items, push, pop, peek, size, and clear operations for both MinBucketQueue and MaxBucketQueue."},"warnings":[{"fix":"Ensure all priorities are integers >= 0.","message":"Bucket priority queue only works with non-negative integer priorities. Using non-integer or negative priorities may cause unexpected behavior.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use object references carefully; consider using unique identifiers.","message":"The queue does not support duplicate items. 'has' and 'contains' methods rely on reference equality, not value equality.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If you need to preserve old items, use 'push' individually instead.","message":"The 'refill' method clears the queue before adding new items; any previously stored items are lost.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'2.1.0':31 'activ':37 'algorithm':59 'base':17,50 'benchmark':54 'bucket':1,9,75,78 'consist':25 'data':11,85,88 'data-structur':84,87 'definit':68 'dequeu':45 'dijkstra':61 'enqueu':43 'extrem':41 'fast':42 'full':65 'heap':49 'heap-bas':48 'ideal':57 'implement':6 'integ':29 'item':18 'javascript':77 'key':23 'latest':34 'like':60 'maintain':38 'make':55 'manag':19 'max':74 'min':72 'offer':40 'oper':46 'optim':13 'outperform':47 'posit':28 'prioriti':2,16,22,51,80,82 'priority-bas':15 'priority-queu':81 'queue':3,10,52,76,79,83 'releas':36 'ship':63 'small':27 'space':24 'stabl':35 'structur':12,86,89 'support':70 'type':67 'typescript':5,66,90 'version':30","created_at":"2026-06-07T16:50:16.714636+00:00","updated_at":"2026-06-07T16:50:16.714636+00:00","problems":[{"fix":"Use import { MinBucketQueue } from 'bucket-priority-queue'.","cause":"Using default import instead of named import.","error":"TypeError: MinBucketQueue is not a constructor"},{"fix":"Run 'npm install bucket-priority-queue' and ensure 'moduleResolution' is set to 'node' or 'node16' in tsconfig.json.","cause":"Missing or incorrect module installation or tsconfig not resolving node_modules.","error":"Cannot find module 'bucket-priority-queue' or its corresponding type declarations."},{"fix":"The error is misleading; priorities are numbers. If using 'Priority' as a type, import it: import type { Priority } from 'bucket-priority-queue'.","cause":"Priority type is exported as a type, but not needed for usage; TypeScript may infer incorrectly.","error":"TS2345: Argument of type 'number' is not assignable to parameter of type 'Priority'."}],"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/keriati/bucket-priority-queue","github":"https://github.com/keriati/bucket-priority-queue","docs":null,"changelog":null,"pypi":null,"npm":"bucket-priority-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["development"],"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}}