{"id":17044252,"url":"https://github.com/ngryman/ds-binary-heap","last_synced_at":"2025-03-23T02:27:09.009Z","repository":{"id":66059176,"uuid":"82476784","full_name":"ngryman/ds-binary-heap","owner":"ngryman","description":"A binary heap data structure in JavaScript.","archived":false,"fork":false,"pushed_at":"2017-10-12T23:40:04.000Z","size":65,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T05:28:24.465Z","etag":null,"topics":["binary-heap","datastructures","heap"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngryman.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-02-19T17:34:46.000Z","updated_at":"2024-04-09T06:25:46.000Z","dependencies_parsed_at":"2023-04-08T19:48:02.248Z","dependency_job_id":null,"html_url":"https://github.com/ngryman/ds-binary-heap","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/ngryman%2Fds-binary-heap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Fds-binary-heap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Fds-binary-heap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Fds-binary-heap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngryman","download_url":"https://codeload.github.com/ngryman/ds-binary-heap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245046761,"owners_count":20552270,"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":["binary-heap","datastructures","heap"],"created_at":"2024-10-14T09:33:41.783Z","updated_at":"2025-03-23T02:27:08.986Z","avatar_url":"https://github.com/ngryman.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"ds-binary-heap\" src=\"https://raw.githubusercontent.com/ngryman/artworks/master/ds-binary-heap/heading/ds-binary-heap@2x.png\" width=\"280\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  A binary heap data structure in JavaScript.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"//travis-ci.org/ngryman/ds-binary-heap\"\u003e\n    \u003cimg alt=\"Build Status\" src=\"https://img.shields.io/travis/ngryman/ds-binary-heap.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"//codecov.io/github/ngryman/ds-binary-heap\"\u003e\n    \u003cimg alt=\"Coverage\" src=\"https://img.shields.io/codecov/c/github/ngryman/ds-binary-heap.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n* * *\n\n## Big-O\n\n        | Access | Search | Insertion  | Deletion\n------- | ------ | ------ | ---------- | --------\nAverage | `Θ(1)` | `Θ(n)` | `Θ(1)`     | `Θ(log n)`\nWorst   | `O(1)` | `O(n)` | `O(log n)` | `O(log n)`\n\n## Install\n\n```bash\nyarn add ds-binary-heap\n```\n\n## API\n\n### constructor\n\nCreate a new binary heap.\n\n**Parameters**\n\n-   `scorer` **\\[[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)]** Function used to score an item.\n-   `comparer` **\\[[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)]** Function used to compare two items scores.\n\n### push\n\nPush an item to the heap.\n\n**Parameters**\n\n-   `item` **Any** \n\n**Examples**\n\n```javascript\nheap.push(1)\nheap.push('foo')\nheap.push({ foo: 'bar' })\n```\n\n### pop\n\nReturn the root of the heap and remove it.\n\n**Examples**\n\n```javascript\nheap.pop() // Hip-Hop! Ok...\n// =\u003e 1\n```\n\nReturns **Any** item\n\n### peek\n\nReturn the root of the heap.\n\n**Examples**\n\n```javascript\nheap.peek()\n// =\u003e 1\n```\n\nReturns **Any** item\n\n### clear\n\nRemove all items form the heap.\n\n**Examples**\n\n```javascript\nheap.clear()\n```\n\n### entries\n\nReturn an array containing all the items.\n\n**Examples**\n\n```javascript\nheap.entries()\n// =\u003e [ 1, 'foo', { foo: 'bar' }]\n```\n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** \n\n### inspect\n\nReturn a string representation of the list.\n\n**Parameters**\n\n-   `depth` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n-   `opts` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n\n**Examples**\n\n```javascript\nlist.inspect()\n// =\u003e [ 1, 'foo', { foo: 'bar' }]\n```\n\nReturns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n### length\n\nReturn the number of items in the list.\n\n**Examples**\n\n```javascript\nlist.length()\n// =\u003e 3\n```\n\nReturns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\n### iterator\n\nIterate over the list.\n\n**Examples**\n\n```javascript\nfor (let item of list) {\n  console.log(item)\n}\n// =\u003e 1\n// =\u003e 'foo'\n// =\u003e { foo: 'bar' }\n```\n\n## License\n\nMIT © [Nicolas Gryman](http://ngryman.sh)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngryman%2Fds-binary-heap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngryman%2Fds-binary-heap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngryman%2Fds-binary-heap/lists"}