{"id":16311470,"url":"https://github.com/robertzhidealx/lytepq","last_synced_at":"2025-10-04T23:36:44.022Z","repository":{"id":48457183,"uuid":"386321672","full_name":"robertzhidealx/lytepq","owner":"robertzhidealx","description":"A small and mighty suite of data structures in JavaScript.","archived":false,"fork":false,"pushed_at":"2022-05-27T22:34:48.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T20:18:05.688Z","etag":null,"topics":["algorithms","array","binary-heap","data-structures","disjoint-sets","javascript","priority-queue","queue","union-find"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/robertzhidealx.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}},"created_at":"2021-07-15T14:36:08.000Z","updated_at":"2022-05-27T22:33:48.000Z","dependencies_parsed_at":"2022-08-24T05:30:51.073Z","dependency_job_id":null,"html_url":"https://github.com/robertzhidealx/lytepq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertzhidealx%2Flytepq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertzhidealx%2Flytepq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertzhidealx%2Flytepq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertzhidealx%2Flytepq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertzhidealx","download_url":"https://codeload.github.com/robertzhidealx/lytepq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248952358,"owners_count":21188427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["algorithms","array","binary-heap","data-structures","disjoint-sets","javascript","priority-queue","queue","union-find"],"created_at":"2024-10-10T21:44:29.300Z","updated_at":"2025-10-04T23:36:38.974Z","avatar_url":"https://github.com/robertzhidealx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LytePQ \u0026middot; [![npm version](https://badge.fury.io/js/lytepq.svg)](https://badge.fury.io/js/lytepq) [![license](https://img.shields.io/github/license/robertzhidealx/lytepq)](https://github.com/robertzhidealx/lytepq/blob/main/LICENSE) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-cyan)](https://github.com/robertzhidealx/lytepq/pulls)\n\nA small and mighty priority queue library in JavaScript.\n\nServicing in parallel with **LyteSets** (under maintenance), a JavaScript disjoint sets library.\n\n## Install\n\nInstall with either Yarn or NPM via `yarn add lytepq` or `npm install lytepq`.\n\n## LytePQ\n\n### Perks\n\n✅ Packed with all basic priority queue operations.\u003cbr /\u003e\n🚀 Unopinionated functionality exposure - you decide how to use LytePQ.\u003cbr /\u003e\n💻 Perfect for competitive programming, online tests, interviews, etc. Dijkstra's in JS made easy!\u003cbr /\u003e\n📔 Comprehensive JSDoc annotations and intellisense.\u003cbr /\u003e\n🔭 TypeScript support.\n\n### Getting Started\n\nImport into your project in the following ways.\n\n```js\nimport { LytePQ } from \"lytepq\"; // ES\n\nconst { LytePQ } = require(\"lytepq\"); // CommonJS\n```\n\n### Demo\n\n```js\n// LytePQ is a min priority queue by default\nconst minQ = new LytePQ();\npq.push(2), pq.push(1), pq.push(3);\nconst smallest = pq.peek(); // returns the smallest item - 1\n\n// creates a max priority queue with a custom comparator function\nconst maxQ = new LytePQ([2, 3, -1], (a, b) =\u003e b - a);\nconst largest = pq.pop(); // removes and returns the largest item - 3\n\n// queue items can be objects with a matching comparator function\nconst objectQ = new LytePQ(\n  [\n    [0, 8],\n    [1, 2],\n    [2, 7],\n  ],\n  (a, b) =\u003e a[1] - b[1]\n);\nconst smallestObj = objectQ.pop(); // [1, 2]\n```\n\n### Advanced Use Cases\n\n```js\nconst minQ = new LytePQ();\npq.push(2), pq.push(1), pq.push(3);\n// removes and returns the first instance of the specified item\nconst specified = pq.pop(2); // 2\n```\n\n\u003c!-- ## LyteSets\n\n### Perks\n\n✅ Packed with all basic disjoint-set operations.\u003cbr /\u003e\n🚀 Two implementations to choose from: array-based or tree-based (under development).\u003cbr /\u003e\n💻 Perfect for competitive programming, online tests, interviews, etc. Core codebase contains as few as 20 lines of code.\u003cbr /\u003e\n📔 Comprehensive JSDoc annotations and intellisense.\u003cbr /\u003e\n🔭 TypeScript support.\n\n### Getting Started\n\n```js\nimport { LyteSets } from \"lytepq\"; // ES\n\nconst { LyteSets } = require(\"lytepq\"); // CommonJS\n```\n\n### Demo\n\n```js\nconst sets = new LyteSets(10);\n\nsets.union(2, 10);\nsets.union(5, 2);\n\n// true\nconst isConnected = sets.query(2, 10) \u0026\u0026 sets.query(2, 5) \u0026\u0026 sets.query(5, 10);\n``` --\u003e\n\n## Contributing\n\nIssues and pull requests are welcome! Contact [me](https://twitter.com/Robert54161541) on Twitter if needed.\n\n## Credits\n\nThis library took inspiration from [Vladimir Agafonkin](https://github.com/mourner)'s [tinyqueue](https://github.com/mourner/tinyqueue).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertzhidealx%2Flytepq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertzhidealx%2Flytepq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertzhidealx%2Flytepq/lists"}