{"id":44827,"library":"elegant-queue","title":"elegant-queue","description":"elegant-queue (v1.0.9) is a high-performance queue implementation for JavaScript and TypeScript that uses a linked list of fixed-size arrays (circular buffers) to achieve O(1) enqueue and dequeue operations. Unlike native array-based queues that suffer from O(n) shifting, this package maintains constant-time operations even with millions of elements. It ships TypeScript definitions, supports both CommonJS and ES Modules, and offers a simple API: enqueue, dequeue, peek, clear, size, and isEmpty. The default internal array size is 4096, but can be configured. Suitable for Node.js and browser environments. Stable release, no recent updates.","status":"active","version":"1.0.9","language":"javascript","source_language":"en","source_url":"https://github.com/seongjin605/elegant-queue","tags":["javascript","queue","elegant-queue","typescript"],"install":[{"cmd":"npm install elegant-queue","lang":"bash","label":"npm"},{"cmd":"yarn add elegant-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add elegant-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Queue is a named export, not a default export. Works with both ESM and CJS.","wrong":"import Queue from 'elegant-queue'","symbol":"Queue","correct":"import { Queue } from 'elegant-queue'"},{"note":"CommonJS requires destructuring to get the named export.","wrong":"const Queue = require('elegant-queue')","symbol":"Queue (CommonJS)","correct":"const { Queue } = require('elegant-queue')"},{"note":"TypeScript types are bundled; no need for deep imports.","wrong":"import { Queue } from 'elegant-queue/src/index'","symbol":"Queue (TypeScript)","correct":"import { Queue } from 'elegant-queue'"}],"quickstart":{"code":"import { Queue } from 'elegant-queue';\n\n// Create a queue (default buffer size 4096)\nconst queue = new Queue<number>();\n\n// Enqueue elements\nqueue.enqueue(10);\nqueue.enqueue(20);\nqueue.enqueue(30);\n\n// Dequeue returns the first element (FIFO)\nconst first = queue.dequeue();\nconsole.log(first); // 10\n\n// Peek without removing\nconsole.log(queue.peek()); // 20\n\n// Check size\nconsole.log(queue.size()); // 2\n\n// Check if empty\nconsole.log(queue.isEmpty()); // false\n\n// Clear all elements\nqueue.clear();\nconsole.log(queue.size()); // 0","lang":"typescript","description":"Demonstrates basic usage: creating a Queue, enqueue, dequeue, peek, size, isEmpty, and clear."},"warnings":[{"fix":"Check queue.isEmpty() before calling dequeue(), or wrap in try-catch.","message":"Dequeue on empty queue throws EmptyQueueException","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use isEmpty() before peek, or catch the exception.","message":"Peek on empty queue throws EmptyQueueException","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"When passing a single argument, if it's a number it sets buffer size; if it's an array it initializes the queue. Do not mix types.","message":"Queue constructor accepts an optional arraySize (number) or an optional iterable (array) to initialize with data.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"N/A","message":"The package has no known deprecated APIs in current version.","severity":"deprecated","affected_versions":"none"}],"env_vars":null,"search_vec":"'1':34 '4096':91 'achiev':32 'api':77 'array':28,42,88 'array-bas':41 'base':43 'browser':100 'buffer':30 'circular':29 'clear':81 'commonj':69 'configur':95 'constant':55 'constant-tim':54 'default':86 'definit':66 'dequeu':37,79 'eleg':2,5,110 'elegant-queu':1,4,109 'element':62 'enqueu':35,78 'environ':101 'es':71 'even':58 'fix':26 'fixed-s':25 'high':11 'high-perform':10 'implement':14 'intern':87 'isempti':84 'javascript':16,107 'link':22 'list':23 'maintain':53 'million':60 'modul':72 'n':49 'nativ':40 'node.js':98 'o':33,48 'offer':74 'oper':38,57 'packag':52 'peek':80 'perform':12 'queue':3,6,13,44,108,111 'recent':105 'releas':103 'shift':50 'ship':64 'simpl':76 'size':27,82,89 'stabl':102 'suffer':46 'suitabl':96 'support':67 'time':56 'typescript':18,65,112 'unlik':39 'updat':106 'use':20 'v1.0.9':7","created_at":"2026-06-07T12:52:01.971320+00:00","updated_at":"2026-06-07T12:52:01.971320+00:00","problems":[{"fix":"Always call isEmpty() before dequeue/peek, or catch the exception.","cause":"Calling dequeue() or peek() on an empty queue.","error":"Error: EmptyQueueException"},{"fix":"Use import { Queue } from 'elegant-queue' instead of import Queue from 'elegant-queue'.","cause":"Using default import instead of named import.","error":"TypeError: queue_1.Queue is not a constructor"},{"fix":"Run 'npm install elegant-queue' and ensure 'node_modules' is included in TypeScript resolution.","cause":"Missing npm install or incorrect tsconfig paths.","error":"Cannot find module 'elegant-queue' or its corresponding type declarations."}],"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/seongjin605/elegant-queue#readme","github":"https://github.com/seongjin605/elegant-queue","docs":null,"changelog":null,"pypi":null,"npm":"elegant-queue","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}}