{"id":24869747,"url":"https://github.com/huseynovvusal/pqjs","last_synced_at":"2026-03-12T05:33:20.114Z","repository":{"id":274461490,"uuid":"922678329","full_name":"huseynovvusal/pqjs","owner":"huseynovvusal","description":"⚡ A fast and lightweight priority queue implementation for JavaScript.","archived":false,"fork":false,"pushed_at":"2025-01-29T07:23:45.000Z","size":664,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T04:52:03.514Z","etag":null,"topics":["algorithms","data-structures","heapq","pqjs","priority-queue"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pqjs","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/huseynovvusal.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-26T20:28:10.000Z","updated_at":"2025-01-29T07:23:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"e78d1a4e-d559-4217-b237-6d790cec8b8c","html_url":"https://github.com/huseynovvusal/pqjs","commit_stats":null,"previous_names":["huseynovvusal/pqjs"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fpqjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fpqjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fpqjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huseynovvusal%2Fpqjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huseynovvusal","download_url":"https://codeload.github.com/huseynovvusal/pqjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665767,"owners_count":21142123,"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","data-structures","heapq","pqjs","priority-queue"],"created_at":"2025-02-01T03:31:51.619Z","updated_at":"2026-03-12T05:33:15.094Z","avatar_url":"https://github.com/huseynovvusal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\r\n    \u003cpicture\u003e\r\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/huseynovvusal/pqjs/refs/heads/main/assets/logo-dark.png\"\u003e\r\n        \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/huseynovvusal/pqjs/refs/heads/main/assets/logo-light.png\"\u003e\r\n        \u003cimg alt=\"Pq.js\" src=\"assets/logo-light.png\" width=\"250\"\u003e\r\n    \u003c/picture\u003e\r\n    \u003cbr/\u003e\r\n    \u003cbr/\u003e\r\n    \u003cp align=\"center\"\u003e\r\n      \u003ca href=\"https://www.npmjs.com/package/pqjs\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/npm/v/pqjs.svg\" alt=\"npm version\"\u003e\r\n\u003c/a\u003e\r\n\u003ca href=\"https://github.com/huseynovvusal/pqjs/blob/main/LICENSE\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/npm/l/pqjs.svg\" alt=\"license\"\u003e\r\n\u003c/a\u003e\r\n\u003ca href=\"https://www.npmjs.com/package/pqjs\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/npm/dt/pqjs.svg\" alt=\"npm downloads\"\u003e\r\n\u003c/a\u003e\r\n    \u003c/p\u003e\r\n    \u003cp align=\"center\"\u003e\r\n        An efficient and easy-to-use priority queue.\r\n    \u003c/p\u003e\r\n\r\n\u003c/div\u003e\r\n\r\n**Pq.js** provides a fast, straightforward priority queue to manage data based on priority. Ideal for sorting, task\r\nscheduling, or implementing priority-based logic in your app.\r\n\r\n- ⚡ Simple and fast priority queue operations.\r\n- 🔽🔼 Supports both **Min-Heap** and **Max-Heap** configurations.\r\n- 🌱 No dependencies.\r\n\r\nPerfect for anyone needing a priority queue implementation in JavaScript.\r\n\r\n## Installation\r\n\r\n```sh\r\nnpm install pqjs\r\n```\r\n\r\n## Usage\r\n\r\n### Importing the PriorityQueue\r\n\r\n```javascript\r\nimport {PriorityQueue} from \"pqjs\"\r\n```\r\n\r\n### Creating a PriorityQueue\r\n\r\n```javascript\r\nconst pq = new PriorityQueue()\r\n```\r\n\r\n### Creating a PriorityQueue with Initial Values\r\n\r\n```javascript\r\nconst initialValues = [10, 5, 20]\r\nconst pq = new PriorityQueue(initialValues)\r\n```\r\n\r\n### Adding Elements\r\n\r\n```javascript\r\npq.push(10)\r\npq.push(5)\r\npq.push(20)\r\n```\r\n\r\n### Accessing the Top Element\r\n\r\n```javascript\r\nconsole.log(pq.top()) // 20 for Max-Heap by default\r\n```\r\n\r\n### Removing the Top Element\r\n\r\n```javascript\r\nconsole.log(pq.pop()) // 20\r\n```\r\n\r\n### Checking if the Queue is Empty\r\n\r\n```javascript\r\nconsole.log(pq.empty()) // false\r\n```\r\n\r\n### Clearing the Queue\r\n\r\n```javascript\r\npq.clear()\r\nconsole.log(pq.empty()) // true\r\n```\r\n\r\n### Converting to an Array\r\n\r\n```javascript\r\nconsole.log(pq.toArray()) // []\r\n```\r\n\r\n### Using a Comparator for Min-Heap\r\n\r\n```javascript\r\nconst minHeapComparator = (a, b) =\u003e b - a\r\nconst minHeap = new PriorityQueue([], minHeapComparator)\r\n\r\nminHeap.push(10)\r\nminHeap.push(5)\r\nminHeap.push(20)\r\n\r\nconsole.log(minHeap.pop()) // 5 for Min-Heap\r\nconsole.log(minHeap.pop()) // 10 for Min-Heap\r\nconsole.log(minHeap.pop()) // 20 for Min-Heap\r\n```\r\n\r\n## License\r\n\r\nMIT © 2025 Vusal Huseynov\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuseynovvusal%2Fpqjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuseynovvusal%2Fpqjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuseynovvusal%2Fpqjs/lists"}