Registry / storage / denque

denque

JSON →
library2.1.0jsnpmunverified

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.

npm install denque
INSTALL
IMPORT
SIG · DENQUE
D
denque
storagejavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Denque
import Denque from 'denque'
const Denque = require('denque').default
ESM default import works directly.
Denque (CommonJS)
const Denque = require('denque')
const Denque = require('denque').Denque
CJS require returns the constructor directly.
Denque type
import type Denque from 'denque'
import { Denque } from 'denque'
TypeScript: use import type for type-only usage.

Create a Denque, push/unshift elements, shift/pop, and peek at index.

import Denque from 'denque'; const queue = new Denque([1, 2, 3]); queue.push(4); // [1,2,3,4] queue.unshift(0); // [0,1,2,3,4] console.log(queue.shift()); // 0 console.log(queue.pop()); // 4 console.log(queue.peekAt(1)); // 2 console.log(queue.length); // 3
Debug
Known issues
gotchaDenque uses a circular buffer: internal capacity may not match length. Calling .toArray() returns a copy of the logical elements.
fix
Use .toArray() or iterate with .get(i) instead of relying on internal array.
affects: all
gotchapeekAt(index) accepts negative indices for reverse indexing (like Array). But -1 returns the last element, not the first.
fix
peekAt(-1) is safe, but be careful with negative out-of-bounds (returns undefined).
affects: all
gotchaDenque does not support .slice(), .splice(), or other Array methods. It only provides deque operations.
fix
Convert to array via .toArray() and then use array methods.
affects: all
deprecatedIn v1.x, .remove(...) existed but was removed in v2. Use .splice()? No, Denque has no splice. Use manual shift/pop or toArray.
fix
Use .toArray() and re-create Denque for removal by index.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'denque' or 'denque' is not a constructor
CommonJS require for default export when package is ESM-only? Denque provides CJS, but some bundlers may mangle.
fix
Use import Denque from 'denque' or const Denque = require('denque') as appropriate.
Denque.peekAt is not a function
Calling static method on instance without parentheses? Actually instance method. Possible typo: using Denque.peekAt instead of instance.peekAt.
fix
const d = new Denque(); d.peekAt(0);
Property 'push' does not exist on type 'Denque<unknown>'
TypeScript strict: type inference issue when not specifying generic.
fix
new Denque<number>([1,2,3]);
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
packagedenque
denque — npm install denque · libregistry