{"id":46843,"library":"yocto-queue","title":"yocto-queue","description":"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.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/yocto-queue","tags":["javascript","queue","data","structure","algorithm","queues","queuing","list","array","typescript"],"install":[{"cmd":"npm install yocto-queue","lang":"bash","label":"npm"},{"cmd":"yarn add yocto-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add yocto-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v1. CommonJS require will fail.","wrong":"const Queue = require('yocto-queue')","symbol":"Queue","correct":"import Queue from 'yocto-queue'"},{"note":"The package exports a default class, not a named export.","wrong":"import { Queue } from 'yocto-queue'","symbol":"Queue","correct":"import Queue from 'yocto-queue'"},{"note":"In CommonJS modules, use dynamic import() and extract .default.","wrong":"const Queue = require('yocto-queue')","symbol":"Queue","correct":"const Queue = (await import('yocto-queue')).default"},{"note":"For TypeScript type-only imports, use import type.","wrong":null,"symbol":"Queue","correct":"import type Queue from 'yocto-queue'"}],"quickstart":{"code":"import Queue from 'yocto-queue';\n\nconst queue = new Queue();\n\nqueue.enqueue('🐶');\nqueue.enqueue('🐱');\nconsole.log(queue.size); // 2\n\nconsole.log(queue.dequeue()); // '🐶'\nconsole.log(queue.dequeue()); // '🐱'\nconsole.log(queue.dequeue()); // undefined\n\nqueue.enqueue('🐭');\nconsole.log(queue.peek()); // '🐭'\nqueue.clear();\nconsole.log(queue.size); // 0","lang":"typescript","description":"Creates a queue, enqueues two items, dequeues them, shows peek and clear."},"warnings":[{"fix":"Use import or dynamic import(). See imports section.","message":"Package is ESM-only starting from v1.0.0. CommonJS require() will throw an error.","severity":"breaking","affected_versions":">=1.0.0"},{"message":"No deprecated features known; package is minimal and stable.","severity":"deprecated"},{"fix":"Use .drain() if you want to remove items during iteration.","message":"Iterating over the queue (e.g., for...of) does not remove items. To dequeue while iterating, use .drain().","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Iterate directly using for...of or drain() instead of spreading.","message":"Spreading the queue into an array ([...queue]) is not recommended for large queues as it is O(n).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use queue.size (no parentheses).","message":".size is a getter property, not a method. Do not call it as a function.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1':12 '1.2.2':32 'algorithm':82 'array':25,72,86 'clear':58 'constant':68 'constant-tim':67 'data':8,80 'depend':44 'dequeu':15,56,70 'design':17 'differenti':65 'drain':59 'drop':21 'drop-in':20 'enqueu':13,55 'esm':48 'esm-on':47 'fifo':6 'guarante':66 'iter':63 'javascript':78 'key':64 'linear':75 'linear-tim':74 'list':85 'mani':28 'method':54 'o':11 'offer':53 'oper':16,30 'peek':57 'perform':27 'queu':84 'queue':3,7,79,83 'recent':37 'releas':38 'replac':23 'shift':29,77 'ship':39 'sinc':50 'size':60 'stabl':34 'structur':9,81 'time':69,76 'tini':5 'type':41 'typescript':40,87 'v1':51 'version':31 'vs':71 'yocto':2 'yocto-queu':1 'zero':43","created_at":"2026-06-07T13:01:54.066282+00:00","updated_at":"2026-06-07T13:01:54.066282+00:00","problems":[{"fix":"Use import Queue from 'yocto-queue' or const Queue = (await import('yocto-queue')).default;","cause":"Package is ESM-only; require() is not supported.","error":"const Queue = require('yocto-queue');\n            ^\nError [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use queue.size without parentheses.","cause":".size is a getter property, not a method.","error":"TypeError: queue.size is not a function"}],"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/sindresorhus/yocto-queue#readme","github":"https://github.com/sindresorhus/yocto-queue","docs":null,"changelog":null,"pypi":null,"npm":"yocto-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"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}}