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.
Queue
✓ import Queue from 'yocto-queue'
✗ const Queue = require('yocto-queue')
ESM-only since v1. CommonJS require will fail.
Queue
✓ import Queue from 'yocto-queue'
✗ import { Queue } from 'yocto-queue'
The package exports a default class, not a named export.
Queue
✓ const Queue = (await import('yocto-queue')).default
✗ const Queue = require('yocto-queue')
In CommonJS modules, use dynamic import() and extract .default.
Queue
✓ import type Queue from 'yocto-queue'
For TypeScript type-only imports, use import type.
Creates a queue, enqueues two items, dequeues them, shows peek and clear.
import Queue from 'yocto-queue';
const queue = new Queue();
queue.enqueue('🐶');
queue.enqueue('🐱');
console.log(queue.size); // 2
console.log(queue.dequeue()); // '🐶'
console.log(queue.dequeue()); // '🐱'
console.log(queue.dequeue()); // undefined
queue.enqueue('🐭');
console.log(queue.peek()); // '🐭'
queue.clear();
console.log(queue.size); // 0
Debug
Known issues
breakingPackage is ESM-only starting from v1.0.0. CommonJS require() will throw an error.fixUse import or dynamic import(). See imports section.
affects: >=1.0.0
deprecatedNo deprecated features known; package is minimal and stable.
gotchaIterating over the queue (e.g., for...of) does not remove items. To dequeue while iterating, use .drain().fixUse .drain() if you want to remove items during iteration.
affects: >=0.0.0
gotchaSpreading the queue into an array ([...queue]) is not recommended for large queues as it is O(n).fixIterate directly using for...of or drain() instead of spreading.
affects: >=0.0.0
gotcha.size is a getter property, not a method. Do not call it as a function.fixUse queue.size (no parentheses).
affects: >=0.0.0
Errors
Common errors & fixes
const Queue = require('yocto-queue');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module
Package is ESM-only; require() is not supported.
fixUse import Queue from 'yocto-queue' or const Queue = (await import('yocto-queue')).default; TypeError: queue.size is not a function
.size is a getter property, not a method.
fixUse queue.size without parentheses.
Audit
Dependencies
No dependency data recorded yet.