{"id":19684016,"url":"https://github.com/bastidood/deno-deque","last_synced_at":"2026-05-11T21:39:34.065Z","repository":{"id":62422228,"uuid":"391313156","full_name":"BastiDood/deno-deque","owner":"BastiDood","description":"A modern double-ended queue for TypeScript/JavaScript.","archived":false,"fork":false,"pushed_at":"2021-08-02T10:32:41.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-26T23:10:41.716Z","etag":null,"topics":["deno","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BastiDood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-31T09:40:00.000Z","updated_at":"2021-08-07T11:50:26.000Z","dependencies_parsed_at":"2022-11-01T17:32:31.868Z","dependency_job_id":null,"html_url":"https://github.com/BastiDood/deno-deque","commit_stats":null,"previous_names":["some-dood/deno-deque"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/BastiDood/deno-deque","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fdeno-deque","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fdeno-deque/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fdeno-deque/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fdeno-deque/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BastiDood","download_url":"https://codeload.github.com/BastiDood/deno-deque/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fdeno-deque/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32914516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-11T17:09:15.040Z","status":"ssl_error","status_checked_at":"2026-05-11T17:08:45.420Z","response_time":120,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["deno","typescript"],"created_at":"2024-11-11T18:16:28.320Z","updated_at":"2026-05-11T21:39:34.049Z","avatar_url":"https://github.com/BastiDood.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deno Deque\r\nA fast zero-dependency [double-ended queue](https://en.wikipedia.org/wiki/Double-ended_queue) written in modern [TypeScript](https://www.typescriptlang.org/) for the [Deno](https://deno.land/) runtime.\r\n\r\n# Acknowledgements\r\nThis project is practically a rewrite of the popular [Denque library](https://github.com/invertase/denque). Due to Denque's minimum compatiblity with Node.js v0.10, the original code uses old JavaScript patterns that no longer apply in modern applications. The goal of this rewrite, then, is to serve as a modern adaptation of the core logic.\r\n\r\n\u003e **DISCLAIMER:** This rewrite is _not_ endorsed by nor affiliated with the [Denque project](https://github.com/invertase/denque) and [its authors](https://invertase.io/).\r\n\r\n# Compatibility and Limitations\r\nSince this project intends to be a rewrite, I have taken the liberty to only include a subset of Denque's features that I consider to be essential. From a pedantic standpoint, a double-ended queue should only support four core operations: `push`, `pop`, and `unshift`, and `shift`.\r\n\r\nHence, splicing operations have been removed from the original code. If splicing operations are a \"must-have\", then perhaps it may be worth reconsidering whether a double-ended queue is the most appropriate data structure for the job.\r\n\r\nAnother removed feature was the ability to indicate some maximum capacity. This was typically a use case for bounded queues. This feature was removed because I have opted to delegate this constraint to user-land. That is, one must manually check the `length` of the queue themselves before inserting into the queue. The overall effect, then, remains the same. If this limitation is truly a deal breaker, please [file an issue](https://github.com/Some-Dood/deno-deque/issues/new/choose) stating your use case.\r\n\r\nFinally, some methods have also been renamed. In particular, [`peekAt`](https://github.com/invertase/denque/blob/0420632a878b271e2d7483c30468a60b4afc9456/README.md#peekAtint-index---dynamic) has been renamed to `at` in accordance with the recently added [`Array.prototype.at`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at).\r\n\r\nWith that said, the next section covers the public interface of the library.\r\n\r\n# Usage\r\n\u003e **NOTE:** _All_ queue operations are `O(1)`.\r\n\r\n```typescript\r\n// In production, please don't forget to lock to a specific version!\r\nimport { Deque } from 'https://deno.land/x/deno_deque/mod.ts';\r\n\r\n// Construct a new double-ended queue.\r\nconst deque = new Deque\u003cnumber\u003e();\r\n\r\n// Insert an item to the **back** of the deque.\r\n// This returns the new length.\r\ndeque.push(100); // 1\r\ndeque.push(200); // 2\r\n\r\n// Insert an item to the **front** of the deque.\r\n// This returns the new length.\r\ndeque.unshift(300); // 3\r\ndeque.unshift(400); // 4\r\n\r\n// Removes and returns the **last** item.\r\ndeque.pop(); // 200\r\n\r\n// Removes and returns the **first** item.\r\ndeque.shift(); // 400\r\n\r\n// Peeks at the item at a specific index (without removing).\r\n// This supports negative indexing.\r\n// Returns `undefined` if out of bounds.\r\ndeque.at(1); // 100\r\n\r\n// Returns whether the deque is empty;\r\ndeque.empty; // false\r\n\r\n// Alias for `deque.at(-1)`.\r\ndeque.back; // 100\r\n\r\n// Alias for `deque.at(0)`.\r\ndeque.front; // 300\r\n\r\n// The number of elements currently in the queue.\r\ndeque.length; // 2\r\n\r\n// The maximum capacity of the inner buffer.\r\n// Typically, one does not need to think about this.\r\ndeque.capacity; // 8\r\n\r\n// Iterate over all elements in the queue (without removing).\r\n// The elements are yielded from front to back.\r\nfor (const num of deque) console.log(num);\r\n\r\n// Copy items in the queue into an array.\r\nArray.from(deque); // [300, 100]\r\n\r\n// Performs a \"soft\" clear.\r\n// Note that this does **not** reset capacity.\r\ndeque.clear();\r\ndeque.empty;       // false\r\ndeque.length;      // 0\r\ndeque.capacity;    // 8\r\nArray.from(deque); // []\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastidood%2Fdeno-deque","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbastidood%2Fdeno-deque","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastidood%2Fdeno-deque/lists"}