{"id":22092190,"url":"https://github.com/pirxpilot/sterta","last_synced_at":"2025-03-23T23:45:25.373Z","repository":{"id":19119205,"uuid":"22348296","full_name":"pirxpilot/sterta","owner":"pirxpilot","description":"binary-heap","archived":false,"fork":false,"pushed_at":"2024-02-07T11:32:46.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-02T07:18:06.510Z","etag":null,"topics":[],"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/pirxpilot.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-28T15:47:06.000Z","updated_at":"2024-02-07T11:09:51.000Z","dependencies_parsed_at":"2022-09-26T22:10:30.447Z","dependency_job_id":null,"html_url":"https://github.com/pirxpilot/sterta","commit_stats":null,"previous_names":["code42day/binary-heap"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fsterta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fsterta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fsterta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fsterta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pirxpilot","download_url":"https://codeload.github.com/pirxpilot/sterta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245186926,"owners_count":20574554,"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":[],"created_at":"2024-12-01T03:08:36.851Z","updated_at":"2025-03-23T23:45:25.345Z","avatar_url":"https://github.com/pirxpilot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM version][npm-image]][npm-url]\n[![Build Status][build-image]][build-url]\n[![Dependency Status][deps-image]][deps-url]\n\n# binary-heap\n\n  [Binary heap](http://en.wikipedia.org/wiki/Binary_heap)\n\n## Installation\n\n```sh\n$ npm install --save conde42day-binary-heap\n```\n\n## Usage\n\n```\n  var h = heap();\n  h.push(5);\n  h.push(2);\n\n  h.pop(); // 2\n  h.pop(); // 5\n  h.pop(); // undefined\n```\n\n## API\n\n### `heap(fn, heapIndex)`\n\n`fn` - compare function, by default numerical comparison resulting in `min-heap`, see tests for `max-heap` example\n`heapIndex` - if truthy, heap will use item's `_heapIndex` property to track its position on the heap, it speeds up item removals, but can slow down operations for smaller heaps\n\n\n### `push(item)`\n\nadds `item` to the heap\n\n### `pop()`\n\npops item from the top of the heap, rebalances the head\n\n### `peek()`\n\nreturns the top of the heap, without removing it\n\n### `rebuild(data)`\n\nrebuilds heap to satisfy comparison constraint, if `data` is provided it is used to reinitialize the heap\n\n### `popAndRebuild()`\n\npop and immediately rebuild the heap, implemented in a slightly more efficient manner than separate `pop()` and\n`rebuild()`- useful when heap needs to be rebalanced after top is removed, because some of the items might have changed\ntheir relative weights\n\n## License\n\nMIT © [Damian Krzeminski](https://pirxpilot.me)\n\n[npm-image]: https://img.shields.io/npm/v/sterta\n[npm-url]: https://npmjs.org/package/sterta\n\n[build-url]: https://github.com/pirxpilot/sterta/actions/workflows/check.yaml\n[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/sterta/check.yaml?branch=main\n\n[deps-image]: https://img.shields.io/librariesio/release/npm/sterta\n[deps-url]: https://libraries.io/npm/sterta\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirxpilot%2Fsterta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpirxpilot%2Fsterta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirxpilot%2Fsterta/lists"}