Registry / devops / yocto-queue

yocto-queue

JSON →
library1.2.2jsnpmunverified

A tiny FIFO queue data structure with O(1) enqueue and dequeue operations, designed as a drop-in replacement for arrays when performing many shift() operations. Version 1.2.2 is stable with no recent releases; ships TypeScript types, has zero dependencies, and is ESM-only since v1. It offers methods: enqueue, dequeue, peek, clear, drain, size, and is iterable. Key differentiator: guarantees constant-time dequeue vs array's linear-time shift.

npm install yocto-queue
INSTALL
IMPORT
SIG · YOCTO-QUEUE
Y
yocto-queue
devopsjavascriptv1.2.2
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.

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.
fix
Use 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().
fix
Use .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).
fix
Iterate 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.
fix
Use 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.
fix
Use 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.
fix
Use queue.size without parentheses.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
20
Resources
yocto-queue — npm install yocto-queue · libregistry