{"id":42628,"library":"denque","title":"Denque","description":"Denque is a high-performance double-ended queue (deque) implementation for JavaScript/Node.js, version 2.1.0. It provides O(1) operations for push, pop, shift, unshift, and random access via peekAt(index). Zero dependencies, ships TypeScript definitions. Maintained by Invertase, used by official Redis, MongoDB, MariaDB, MySQL and Redis clients. Outperforms other deque libraries like double-ended-queue in benchmarks.","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/invertase/denque","tags":["javascript","data-structure","data-structures","queue","double","end","ended","deque","denque","typescript"],"install":[{"cmd":"npm install denque","lang":"bash","label":"npm"},{"cmd":"yarn add denque","lang":"bash","label":"yarn"},{"cmd":"pnpm add denque","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import works directly.","wrong":"const Denque = require('denque').default","symbol":"Denque","correct":"import Denque from 'denque'"},{"note":"CJS require returns the constructor directly.","wrong":"const Denque = require('denque').Denque","symbol":"Denque (CommonJS)","correct":"const Denque = require('denque')"},{"note":"TypeScript: use import type for type-only usage.","wrong":"import { Denque } from 'denque'","symbol":"Denque type","correct":"import type Denque from 'denque'"}],"quickstart":{"code":"import Denque from 'denque';\n\nconst queue = new Denque([1, 2, 3]);\nqueue.push(4);       // [1,2,3,4]\nqueue.unshift(0);    // [0,1,2,3,4]\nconsole.log(queue.shift()); // 0\nconsole.log(queue.pop());   // 4\nconsole.log(queue.peekAt(1)); // 2\nconsole.log(queue.length);  // 3","lang":"typescript","description":"Create a Denque, push/unshift elements, shift/pop, and peek at index."},"warnings":[{"fix":"Use .toArray() or iterate with .get(i) instead of relying on internal array.","message":"Denque uses a circular buffer: internal capacity may not match length. Calling .toArray() returns a copy of the logical elements.","severity":"gotcha","affected_versions":"all"},{"fix":"peekAt(-1) is safe, but be careful with negative out-of-bounds (returns undefined).","message":"peekAt(index) accepts negative indices for reverse indexing (like Array). But -1 returns the last element, not the first.","severity":"gotcha","affected_versions":"all"},{"fix":"Convert to array via .toArray() and then use array methods.","message":"Denque does not support .slice(), .splice(), or other Array methods. It only provides deque operations.","severity":"gotcha","affected_versions":"all"},{"fix":"Use .toArray() and re-create Denque for removal by index.","message":"In v1.x, .remove(...) existed but was removed in v2. Use .splice()? No, Denque has no splice. Use manual shift/pop or toArray.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'1':21 '2.1.0':17 'access':30 'benchmark':62 'client':51 'data':65,68 'data-structur':64,67 'definit':38 'denqu':1,2,75 'depend':35 'dequ':12,54,74 'doubl':9,58,71 'double-end':8 'double-ended-queu':57 'end':10,59,72,73 'high':6 'high-perform':5 'implement':13 'index':33 'invertas':41 'javascript':63 'javascript/node.js':15 'librari':55 'like':56 'maintain':39 'mariadb':47 'mongodb':46 'mysql':48 'o':20 'offici':44 'oper':22 'outperform':52 'peekat':32 'perform':7 'pop':25 'provid':19 'push':24 'queue':11,60,70 'random':29 'redi':45,50 'shift':26 'ship':36 'structur':66,69 'typescript':37,76 'unshift':27 'use':42 'version':16 'via':31 'zero':34","created_at":"2026-06-05T16:55:53.607475+00:00","updated_at":"2026-06-05T16:55:53.607475+00:00","problems":[{"fix":"Use import Denque from 'denque' or const Denque = require('denque') as appropriate.","cause":"CommonJS require for default export when package is ESM-only? Denque provides CJS, but some bundlers may mangle.","error":"Cannot find module 'denque' or 'denque' is not a constructor"},{"fix":"const d = new Denque(); d.peekAt(0);","cause":"Calling static method on instance without parentheses? Actually instance method. Possible typo: using Denque.peekAt instead of instance.peekAt.","error":"Denque.peekAt is not a function"},{"fix":"new Denque<number>([1,2,3]);","cause":"TypeScript strict: type inference issue when not specifying generic.","error":"Property 'push' does not exist on type 'Denque<unknown>'"}],"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://docs.page/invertase/denque","github":"https://github.com/invertase/denque","docs":null,"changelog":null,"pypi":null,"npm":"denque","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-05","next_check":"2026-09-03","install_tag":null}}