{"library":"queue-typescript","title":"Generic TypeScript Queue","description":"queue-typescript is a minimalist TypeScript library that provides a generic queue data structure. Currently at version 1.0.1, it offers a stable and lightweight solution for managing queues in TypeScript and JavaScript projects. The library distinguishes itself by its full support for TypeScript generics, allowing developers to create type-safe queues for any data type, including primitive types, objects, or custom classes, ensuring compile-time type checking. It also adheres to both the JavaScript iterator and iterable protocols, enabling seamless integration with modern JavaScript features such as `for...of` loops, the spread operator (`...`), and array deconstruction. Internally, `queue-typescript` relies on the `linked-list-typescript` package for its underlying data storage, contributing to efficient enqueue and dequeue operations. This package focuses on core queue functionality, delivering a straightforward, performant, and type-safe queue implementation without unnecessary overhead or additional utilities. Given its singular purpose and stable API, a rapid release cadence is not expected.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install queue-typescript"],"cli":null},"imports":["import { Queue } from 'queue-typescript';","const { Queue } = require('queue-typescript');","let myQueue: Queue<string> = new Queue<string>();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Queue } from 'queue-typescript';\n\n// Create a new queue initialized with numbers\nlet numberQueue = new Queue<number>(10, 20, 30);\nconsole.log('Initial queue length:', numberQueue.length); // Expected: 3\nconsole.log('Front element:', numberQueue.front); // Expected: 10\n\n// Enqueue new items\nnumberQueue.enqueue(40);\nnumberQueue.enqueue(50);\nconsole.log('Queue after enqueuing:', numberQueue.length); // Expected: 5\n\n// Iterate through the queue using for...of\nconsole.log('Queue elements:');\nfor (const item of numberQueue) {\n  console.log(item);\n}\n// Expected: 10, 20, 30, 40, 50 (each on a new line)\n\n// Deconstruct the queue\nconst [first, second, ...rest] = numberQueue;\nconsole.log('First element (deconstructed):', first);   // Expected: 10\nconsole.log('Second element (deconstructed):', second); // Expected: 20\nconsole.log('Remaining elements (deconstructed):', rest); // Expected: [30, 40, 50] (or similar array representation)\n","lang":"typescript","description":"This example demonstrates how to create, initialize, enqueue items into, and iterate through a generic TypeScript Queue, showcasing its iterable protocol support.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}