{"id":41055001,"url":"https://github.com/typescript-package/queue","last_synced_at":"2026-01-22T11:35:41.364Z","repository":{"id":271133190,"uuid":"912443216","full_name":"typescript-package/queue","owner":"typescript-package","description":"A lightweight TypeScript library for managing various queue and stack structures.","archived":false,"fork":false,"pushed_at":"2025-01-19T01:02:16.000Z","size":94,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T05:20:44.463Z","etag":null,"topics":["queue","stack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typescript-package.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-05T15:38:07.000Z","updated_at":"2025-10-09T20:13:34.000Z","dependencies_parsed_at":"2025-01-05T18:55:08.842Z","dependency_job_id":"34ab1da9-a378-4dbf-9f26-164d3488d328","html_url":"https://github.com/typescript-package/queue","commit_stats":null,"previous_names":["typescript-package/queue"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/typescript-package/queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typescript-package","download_url":"https://codeload.github.com/typescript-package/queue/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fqueue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28662165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["queue","stack"],"created_at":"2026-01-22T11:35:41.259Z","updated_at":"2026-01-22T11:35:41.354Z","avatar_url":"https://github.com/typescript-package.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ca href=\"https://www.typescriptlang.org/\"\u003e\n  \u003cimg\n    src=\"https://raw.githubusercontent.com/typescript-package/core/refs/heads/main/ts-package-barcode-logo-512.png\"\n    width=\"20%\"\n    title=\"@typescript-package/queue\"\n  /\u003e\n\u003c/a\u003e\n\n## typescript-package/queue\n\nA lightweight TypeScript library for managing various queue and stack structures.\n\n\u003c!-- npm badge --\u003e\n[![npm version][typescript-package-npm-badge-svg]][typescript-package-npm-badge]\n[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues]\n[![GitHub license][typescript-package-badge-license]][typescript-package-license]\n\n\u003cbr\u003e\n\n## Table of contents\n\n* [Installation](#installation)\n* [Api](#api)\n  * [`Elements`](#elements)\n  * [`Processing`](#processing)\n  * [`TaskQueue`](#taskqueue)\n  * [`Tasks`](#tasks)\n  * [`Queue`](#queue)\n  * [`Stack`](#stack)\n* [Git](#git)\n  * [Commit](#commit)\n  * [Versioning](#versioning)\n* [License](#license)\n\n## Installation\n\n```bash\nnpm install @typescript-package/queue\n```\n\n## Api\n\n```typescript\nimport {\n  // Class.\n  Elements,\n  Processing,\n  TaskQueue,\n  Tasks,\n  // Abstract.\n  Queue,\n  Stack\n} from '@typescript-package/queue';\n```\n\n### `Elements`\n\n`Array` state elements in data structures such as `Stack` and `Queue`.\n\n```typescript\nimport { Elements } from '@typescript-package/queue';\n\nlet elements = new Elements(\n  [1, 2, 3, 4], // Array type elements.\n  15 // Maximum size of the elements.\n);\n\n// Appends the value at the end of an array state.\nelements.append(5);\nconsole.log(elements.state); // Output: [1, 2, 3, 4, 5]\n\n// Inserts the value at the specified index into the array state.\nelements.insert(2, 10);\nconsole.log(elements.state); // Output: [1, 2, 10, 3, 4, 5]\n\n// Adds the values at the beginning of array state.\nelements.prepend(0);\nconsole.log(elements.state); // Output: [0, 1, 2, 10, 3, 4, 5]\n\n// Updates the value at the index in the array state.\nelements.update(0, 127);\nconsole.log(elements.state); // Output: [127, 1, 2, 10, 3, 4, 5]\n```\n\n### `Processing`\n\nClass designed for asynchronous processing the promises of `void`.\n\n```typescript\nimport { Processing } from '@typescript-package/queue';\n\nconsole.group(`Processing`);\n\nlet processing = new Processing();\n\n// Adds the promise to the processing and on finally remove.\nprocessing.add(new Promise((resolve, reject) =\u003e resolve()));\n\n// Adds the promise to the processing without removing.\nprocessing.add(new Promise((resolve, reject) =\u003e resolve()));\n\n// Returns the first process.\nconsole.log(`first, `, processing.first);\n\n// Returns the last process.\nconsole.log(`last, `, processing.last);\n\n// Removes the first process.\nprocessing.delete();\n\nconsole.groupEnd();\n```\n\n### `TaskQueue`\n\nA task queue that processes elements concurrently with a specified concurrency limit.\n\n```typescript\nimport { TaskQueue } from '@typescript-package/queue';\n\nconsole.group(`TaskQueue`);\n\n// Initialize the `TaskQueue`.\ntaskQueue = new TaskQueue(\n  3, // concurrency\n  10, // size\n  1, 2, 3 // items\n);\n\n// The maximum number of elements that can be processed concurrently.\nconsole.log(`concurrency, `, taskQueue.concurrency); // Output: 2\n\n// A set containing all elements that have been successfully processed.\nconsole.log(`processed, `, taskQueue.processed); // Output: Set(0)\n\n// Checks whether the queue is empty.\nconsole.log(`isEmpty(), `, taskQueue.isEmpty()); // Output: false\n\n// Checks whether the queue is full.\nconsole.log(`isFull(), `, taskQueue.isFull()); // Output: false\n\n// The maximum queue size.\nconsole.log(`size, `, taskQueue.size); // Output: 10\n\n// The actual queue Elements state - raw array state of the queue.\nconsole.log(`state, `, taskQueue.state); // Output: [1, 2, 3]\n\n// The actual queue length.\nconsole.log(`length, `, taskQueue.length); // Output: 3\n\n// Adds a new element to the queue.\nconsole.log(`enqueue(4), `, taskQueue.enqueue(4));\n\n// The actual queue length.\nconsole.log(`length, `, taskQueue.length); // Output: 4\n\n// Returns the first element in the queue.\nconsole.log(`peek(), `, taskQueue.peek()); // Output: 1\n\n// Returns the first element in the queue.\nconsole.log(`dequeue(), `, taskQueue.dequeue()); // Output: 1\n\n// The actual queue length.\nconsole.log(`length, `, taskQueue.length); // Output: 3\n\n// Adds to the full.\ntaskQueue.enqueue(5).enqueue(6).enqueue(7).enqueue(8).enqueue(9).enqueue(10).enqueue(11);\n\n// The actual queue Elements state - raw array state of the queue.\nconsole.log(`state, `, taskQueue.state); // Output: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n\n// Waits for all elements in the queue to be processed and returns the set of processed elements.\ntaskQueue.onCompleted().then(\n  processed =\u003e console.log(`TaskQueue completed`, processed), // Output: Completed Set(10)\n  reason =\u003e console.log(reason)\n);\n\n// Starts processing elements in the queue using the provided callback function.\n// processingQueue.run(element =\u003e console.log(`Processed. `, element)); // Output: Processed {element}\n\ntaskQueue.asyncRun(element =\u003e console.log(`TaskQueue processed. `, element)).finally(() =\u003e console.log(`TaskQueue async Run Completed.`)); // Output: Processed {element}\n\n// A set containing all elements that have been successfully processed.\nconsole.log(`processed, `, taskQueue.processed); // Output: Set(10)\n\nconsole.groupEnd();\n```\n\n### `Tasks`\n\nA class designed to manage and execute a collection of asynchronous tasks with concurrently control or synchronous tasks.\n\n```typescript\nimport { Tasks } from '@typescript-package/queue';\n\nconsole.group(`Tasks`);\n\nlet tasks = new Tasks\u003cnumber\u003e(true, 3);\n\ntasks.debug().asyncRun(\n  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],\n  element =\u003e {},\n  () =\u003e {},\n  element =\u003e {},\n  'default'\n).then(processed =\u003e {\n  console.log(`then()`, processed);\n}).finally(() =\u003e {\n  console.log(`finally()`);\n})\n\nconsole.groupEnd();\n```\n\n### `Queue`\n\nA standard FIFO (First In, First Out) queue.\n\n```typescript\nimport { Queue } from '@typescript-package/queue';\n\n// Initialize the new `Queue`.\nlet queue = new Queue(\n  10, // size\n  1, 2, 3 // item\n);\n\n// Adds a new element to the queue.\nqueue.enqueue(4);\n\n// The actual queue Elements state - raw array state of the queue.\nconsole.log(`state,`, queue.state); // Output: [1, 2, 3, 4]\n\n// Returns the first element in the queue.\nconsole.log(`peek(), `, queue.peek()); // Output: 1\n\n// Checks if the queue is empty.\nconsole.log(`isEmpty(),`, queue.isEmpty()); // Output: false\n\n// The maximum queue size.\nconsole.log(`size,`, queue.size); // Output: 10\n\n// The actual queue Elements state - raw array state of the queue.\nconsole.log(`state,`, queue.state); // Output: [1, 2, 3, 4]\n\n// Adds to the full.\nqueue.enqueue(5).enqueue(6).enqueue(7).enqueue(8).enqueue(9).enqueue(10);\n\n// Checks whether the queue is full.\nconsole.log(`isFull(), `, queue.isFull()); // Output: true\n\ntry {\n  queue.enqueue(11);\n} catch(error) {\n  console.log(error); // Error: Queue is full.\n}\n\n// Clears the queue.\nconsole.log(`clear(), `, queue.clear());\n\n// Checks if the queue is empty.\nconsole.log(`isEmpty(),`, queue.isEmpty()); // Output: true\n\n// The actual queue Elements state - raw array state of the queue.\nconsole.log(`state,`, queue.state); // Output: []\n\n```\n\n### `Stack`\n\nA standard LIFO (Last In, First Out) queue.\n\n```typescript\nimport { Stack } from '@typescript-package/queue';\n\n// Initialize the `Stack`.\nlet stack = new Stack(\n  10, // size\n  1, 2, 3 // items\n);\n\n// The actual stack length.\nconsole.log(`length, `, stack.length); // Output: 3\n\n// Adds a new element on the stack.\nstack.push(4); \n\n// The maximum stack size.\nconsole.log(`size, `, stack.size); // Output: 10\n\n// The actual stack length.\nconsole.log(`length, `, stack.length); // Output: 4\n\n// Returns the top element on the stack.\nconsole.log(`peek(), `, stack.peek()); // Output: 4\n\n// The actual stack `Elements` state.\nconsole.log(`state, `, stack.state); // Output: [1, 2, 3, 4]\n\n// Removes and returns the top element from the stack.\nconsole.log(`pop(), `, stack.pop()); // Output: 4\n\n// The actual stack `Elements` state.\nconsole.log(`state, `, stack.state); // Output: [1, 2, 3]\n\n// Adds to the full.\nstack.push(4).push(5).push(6).push(7).push(8).push(9).push(10);\n\n// The actual stack `Elements` state.\nconsole.log(`state, `, stack.state); // Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\n// Checks if the stack is full.\nconsole.log(`isFull(), `, stack.isFull()); // Output: true\n\n// Clears the queue.\nstack.clear()\n\n// The actual stack `Elements` state.\nconsole.log(`state, `, stack.state); // Output: []\nconsole.log(`isEmpty(), `, stack.isEmpty()); // Output: true\n```\n\n## GIT\n\n### Commit\n\n* [AngularJS Git Commit Message Conventions][git-commit-angular]\n* [Karma Git Commit Msg][git-commit-karma]\n* [Conventional Commits][git-commit-conventional]\n\n### Versioning\n\n[Semantic Versioning 2.0.0][git-semver]\n\n**Given a version number MAJOR.MINOR.PATCH, increment the:**\n\n* MAJOR version when you make incompatible API changes,\n* MINOR version when you add functionality in a backwards-compatible manner, and\n* PATCH version when you make backwards-compatible bug fixes.\n\nAdditional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.\n\n**FAQ**\nHow should I deal with revisions in the 0.y.z initial development phase?\n\n\u003e The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.\n\nHow do I know when to release 1.0.0?\n\n\u003e If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.\n\n## License\n\nMIT © typescript-package ([license][typescript-package-license])\n\n\u003c!-- This package: typescript-package  --\u003e\n  \u003c!-- GitHub: badges --\u003e\n  [typescript-package-badge-issues]: https://img.shields.io/github/issues/typescript-package/queue\n  [isscript-package-badge-forks]: https://img.shields.io/github/forks/typescript-package/queue\n  [typescript-package-badge-stars]: https://img.shields.io/github/stars/typescript-package/queue\n  [typescript-package-badge-license]: https://img.shields.io/github/license/typescript-package/queue\n  \u003c!-- GitHub: badges links --\u003e\n  [typescript-package-issues]: https://github.com/typescript-package/queue/issues\n  [typescript-package-forks]: https://github.com/typescript-package/queue/network\n  [typescript-package-license]: https://github.com/typescript-package/queue/blob/master/LICENSE\n  [typescript-package-stars]: https://github.com/typescript-package/queue/stargazers\n\u003c!-- This package --\u003e\n\n\u003c!-- Package: typescript-package --\u003e\n  \u003c!-- npm --\u003e\n  [typescript-package-npm-badge-svg]: https://badge.fury.io/js/@typescript-package%2Fqueue.svg\n  [typescript-package-npm-badge]: https://badge.fury.io/js/@typescript-package%2Fqueue\n\n\u003c!-- GIT --\u003e\n[git-semver]: http://semver.org/\n\n\u003c!-- GIT: commit --\u003e\n[git-commit-angular]: https://gist.github.com/stephenparish/9941e89d80e2bc58a153\n[git-commit-karma]: http://karma-runner.github.io/0.10/dev/git-commit-msg.html\n[git-commit-conventional]: https://www.conventionalcommits.org/en/v1.0.0/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypescript-package%2Fqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypescript-package%2Fqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypescript-package%2Fqueue/lists"}